Vote count:
0
As part of my project, I am reading a string from file and then encrypting it using AES. I convert the encrypted byte array to string using BASE64, and then write the string back to disk as say file F1. Later, I am reading the written values back from F1, and decoding it using decodeBuffer() to obtain the original encrypted byte array.
However, the byte array returned by decodeBuffer() is of different length than what I had encoded earlier. The sequence of operations is as follows :
byteEncryptedArray = aesCipher.doFinal(string1); temp = new sun.misc.BASE64Encoder().encode(byteEncryptedArray);
temp is then written to file F1.
Read temp back from F1.
byteDecryptedArray = new sun.misc.BASE64Decoder().decodeBuffer(temp);
In my understanding byteDecryptedArray should be same as byteEncryptedArray. However, i am getting byte arrays of different length.
Would be very helpful if someone can point out the mistake.
Thanks!
Decoding using decodeBuffer() results in byte array of incorrect length
Aucun commentaire:
Enregistrer un commentaire