package com.dtflys.forest.utils;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;


/**
 * Base64字符串与字节码转换工具
 * @author gongjun[dt_flys@hotmail.com]
 * @since 2020-08-04 19:05
 */

public class Base64Utils {

	public static String simpleEncode(byte[] data) {
		return new BASE64Encoder().encode(data);
	}

	public static byte[] simpleDecode(String str) {
		try {
			return new BASE64Decoder().decodeBuffer(str);
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}

    public static String encode(String str){
    	return new BASE64Encoder().encode(str.getBytes());
    }

    public static String decode(String str){
    	try {
			return new String(new BASE64Decoder().decodeBuffer(str));
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
    }

}

@@ -27,16 +27,62 @@
 utils;%0A%0A
+import org.apache.xerces.impl.dv.util.Base64;%0A
 import s
@@ -350,35 +350,22 @@
 %09return 
-new BASE64Encoder()
+Base64
 .encode(
@@ -430,135 +430,35 @@
 %7B%0A%09%09
-try %7B%0A%09%09%09return new BASE64Decoder()
+return Base64
 .decode
-Buffer
 (str);%0A
-%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%09return null;%0A%09%09%7D%0A
 %09%7D%0A%0A
@@ -506,20 +506,17 @@
 r)%7B%0A
-    
+%09
 %09return 
 new 
@@ -515,27 +515,14 @@
 urn 
-new BASE64Encoder()
+Base64
 .enc
@@ -598,20 +598,8 @@
 r)%7B%0A
-    %09try %7B%0A%09
 %09%09re
@@ -618,48 +618,29 @@
 ing(
-new BASE64Decoder()
+Base64
 .decode
-Buffer
 (str));%0A
 %09%09%7D 
@@ -639,80 +639,8 @@
 ));%0A
-%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%09return null;%0A%09%09%7D%0A
     

将BASE64Encoder和BASE64Decoder替换成Base64.encode和Base64.decode