how to encode the ciphertext
the file abc.txt has several lines of ciphertext. i want to encode the l开发者_如何转开发ine of ciphertext into hex encode or base64 before putting in string srr . is there any way i can do it ?
bufferedReader = new BufferedReader(new FileReader("abc.txt"));
String srr = null;
srr = bufferedReader.readLine()
What kind of cipertext is stored in abc.txt
? If it's binary, you shouldn't use a FileReader
to read it, because FileReader
is using some character encoding that could change your input bytes. Use a FileInputStream
instead.
If you want to encode it in Base64 then you can use Commons Codec:
http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
or you can hex encode:
http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Hex.html
精彩评论