替换 sun.misc.BASE64Encoder

原因

java1.8版本后的jdk已经不再支持sun.misc.BASE64Decoder和sun.misc.BASE64Encoder。

 

解决

使用 org.apache.commons.codec.binary.Base64 替换:

 1      /**
 2        * BASE64解码
 3      */
 4     public static byte[] decryptBASE64(String key) throws Exception {
 5         //return (new BASE64Decoder()).decodeBuffer(key);
 6         return Base64.decodeBase64(key); 
 7     }
 8 
 9     /**
10      * BASE64编码
11      */
12     public static String encryptBASE64(byte[] key) throws Exception {
13         //return (new BASE64Encoder()).encodeBuffer(key);
14         return Base64.encodeBase64String(key);
15 
16     }

 

posted @ 2024-04-23 14:07  mzjnumber1  阅读(63)  评论(0编辑  收藏  举报