wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes sending an encrypted byte array through the net Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "sending an encrypted byte array through the net" Watch "sending an encrypted byte array through the net" New topic
Author

sending an encrypted byte array through the net

Alessandro Brawerman
Greenhorn

Joined: Sep 22, 2003
Posts: 22
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.
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
Could it be because the result is longer than 64 bytes?
 
 
subject: sending an encrypted byte array through the net
 
Similar Threads
How to convert byte array to string array ?
Networking
sending an encrypted byte array through a socket
Need Help regarding UDP streaming
End of file JPG images