Tay Thotheolh wrote:Hi. How do I convert byte[] to String like 'AEUKHJBJKBJJKBKJBKBB...' ? I am trying to encrypt a file and it returns a byte[]. I want to write the encrypted content to a file to store it so I thought it would be best to write to some String like the above mentioned. How do I do so ?
It depends on the type of file. There is a constructor that takes a byte array, but keep in mind that the result of an encryption should be binary data. So, you'll have a string that is binary data -- which doesn't work very well if you write it to a text file. And... if you are going to write to a binary file, it may be best to write the byte array directly.
Anyway, if it is a text file, then you need to encode the string... convert the binary data to a readable string. Base64 encoding is probably the most common encoding standard. And there should be
Java libs for that.
Henry