()
| 64 | |
| 65 | // 编码请求包(带加密) |
| 66 | public byte[] encode() { |
| 67 | // 加密数据 |
| 68 | byte[] encryptedData = xorProcess(data); |
| 69 | |
| 70 | ByteBuffer buffer = ByteBuffer.allocate(MAGIC_PREFIX.length + 5 + length); |
| 71 | buffer.put(MAGIC_PREFIX); |
| 72 | buffer.put(type); |
| 73 | buffer.putInt(length); |
| 74 | if (encryptedData != null && length > 0) { |
| 75 | buffer.put(encryptedData); |
| 76 | } |
| 77 | return buffer.array(); |
| 78 | } |
| 79 | |
| 80 | // 解码请求包(带解密) |
| 81 | public static Request decode(byte[] rawData) { |
no test coverage detected