()
| 124 | |
| 125 | // 编码响应包(带加密) |
| 126 | public byte[] encode() { |
| 127 | // 加密数据 |
| 128 | byte[] encryptedData = xorProcess(data); |
| 129 | |
| 130 | ByteBuffer buffer = ByteBuffer.allocate(MAGIC_PREFIX.length + 5 + length); |
| 131 | buffer.put(MAGIC_PREFIX); |
| 132 | buffer.put(type); |
| 133 | buffer.putInt(length); |
| 134 | buffer.put(status); |
| 135 | if (encryptedData != null && encryptedData.length > 0) { |
| 136 | buffer.put(encryptedData); |
| 137 | } |
| 138 | return buffer.array(); |
| 139 | } |
| 140 | |
| 141 | // 解码响应包(带解密) |
| 142 | public static Response decode(byte[] rawData) { |
nothing calls this directly
no test coverage detected