轉載:https://blog.csdn.net/qq_29178991/article/details/79666924
sun.misc.BASE64Encoder 不建議使用java.sun自帶包中的內容
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);
替換為
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);