sun.misc.BASE64Encoder 不建议使用java.sun自带包中的内容


import sun.misc.BASE64Decoder;

在项目中,设计到64位编码的。有时开发会用到JDK中自带的BASE64工具。但sun公司是建议不这样做的。尤其是更新了JDK版本,项目甚至还存在保存的信息。

可引用 import org.apache.commons.codec.binary.Base64;进行替换

一种解决方案:

原来使用的JDK自带jar包中的

return new  BASE64Encoder().encode(encrypted);

替换为
    import org.apache.commons.codec.binary.Base64;
    return Base64.encodeBase64String(encrypted);


        byte[] encrypted1 = new BASE64Decoder().decodeBuffer(text);   
替换为
    import org.apache.commons.codec.binary.Base64;
    byte[] encrypted1 =Base64.decodeBase64(text);    


原文链接:https://blog.csdn.net/qq_29178991/article/details/79666924

posted on 2019-10-10 15:25  腾逸  阅读(11266)  评论(0编辑  收藏  举报