开发者

how to encode the ciphertext

开发者 https://www.devze.com 2022-12-12 08:12 出处:网络
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 ?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消