Hello there! Can someone please help me out with a dilemma...
I encrypted a string, and the cipher.doFinal that I used to encrypt returned a byte[]. I did
String encrypted = new String(cipher.doFinal(....));
Then when decrypting the same string I did this:
cipher.doFinal(encrypted.getBytes()...);
At this point, the cipher class complained saying that it's corrupted. But if I keep it in a byte array, it works fine:
byte[] encrypted = cipher.doFinal(....);
cipher.doFinal(encrypted...);
How can I safely store the byte[] in a string and convert it back perfectly... The reason why I need it in a string is because I have to send the encrypted data to a server over HTTP as a string.
Thank you!
Edited by: Arrowx7 on Jun 27, 2010 12:53 PM