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

转载自:https://blog.csdn.net/qq_29178991/article/details/79666924

import sun.misc.BASE64Encoder;

import sun.misc.BASE64Decoder;

在项目中,设计到64位编码的。有时开发会用到JDK中自带的BASE64工具。但sun公司是建议不这样做的。尤其是更新了JDK版本,项目甚至还存在保存的信息。可引用 import org.apache.commons.codec.binary.Base64;进行替换

一种解决方案:

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

return new  BASE64Encoder().encode(encrypted);

替换为

 
  1. import org.apache.commons.codec.binary.Base64;

  2. return Base64.encodeBase64String(encrypted);

		byte[] encrypted1 = new BASE64Decoder().decodeBuffer(text);	

替换为

import org.apache.commons.codec.binary.Base64;
byte[] encrypted1 =Base64.decodeBase64(text);	

 

猜你喜欢

转载自blog.csdn.net/idongit/article/details/82504409
今日推荐