Hi All,
Need a help.
I wrote a java ServerSocket and client.
When client passes a string (i.e. �Hello world�) to server, server reads it correctly.
is = new BufferedReader(new InputStreamReader(clientSocket
.getInputStream()));
is.readLine();
But in client side I need to do some simple encryption.
opStr = " Hello world ";
byte[] messageBytes = opStr.getBytes();
int s = 12;
byte b = (byte)s;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i = 0;
for (i = 0; i < messageBytes.length; i++) {
messageBytes[i] = (byte)(messageBytes*b);
}
baos.write(messageBytes);
os.write(baos.toByteArray());
os.flush();
So please let me know, from server side, how can I read these response and construct the original string (i.e. �Hello world�).
How to read the byte stream?
Decrypt the code?
And construct the original string?
I tried following but not working as expected.
byte[] newByte = new byte[11];
while(((ch = is.read()) != -1))
{
newByte[cnt] = (byte)(ch);
}
String newStr = new String(newByte);Edited by: galajava on Dec 2, 2007 5:45 AM