posted 19 years ago
Hi all,
I'm trying to send an encrypted byte array through a socket. The other side (the client) has to read it and decrypt it. The problem is that the client is not receiving the encrypted byte array correct. Below follows the code I have:
---- sending the encrypted byte array (server side)
byte[] data = "test".getBytes();
byte[] result = cipher1.doFinal(data);
OutputStream os = connection.getOutputStream();
os.write(result);
os.flush();
----- receiving the encrypted byte array (client side)
InputStream bin = connection.getInputStream();
byte[] input = new byte[64];
for(int i = 0; i < input.length; i++) {
int b = bin.read();
if(b == -1) break;
input[i] = (byte) b;
}
When I check if input is equal to result, I get a no as answer. Is anything wrong with my code?
Thanks a lot.
Alessandro.