本文介绍了如何将sun.misc.BASE64Encoder转换为org.apache.commons.codec.binary.Base64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为sun.misc.BASE64Encoder
使用以下代码:
BASE64Decoder decoder = new BASE64Decoder();
byte[] saltArray = decoder.decodeBuffer(saltD);
byte[] ciphertextArray = decoder.decodeBuffer(ciphertext);
,并希望将其转换为org.apache.commons.codec.binary.Base64
.我已经遍历了API,文档等,但是找不到与之相匹配并给出相同结果值的东西.
and would like to convert it to org.apache.commons.codec.binary.Base64
. I've gone through the APIs, the docs, etc., but I can't find something that seems to match and give the same resulting values.
推荐答案
实际上几乎完全相同:
Base64 decoder = new Base64();
byte[] saltArray = decoder.decode(saltD);
byte[] ciphertextArray = decoder.decode(ciphertext);
用于解码:
String saltString = encoder.encodeToString(salt);
String ciphertextString = encoder.encodeToString(ciphertext);
最后一个更难,因为您在末尾使用了"toString".
This last one was tougher because you use "toString" at the end.
这篇关于如何将sun.misc.BASE64Encoder转换为org.apache.commons.codec.binary.Base64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!