import java.util.Base64;
public class Base64Untis {
public static String encode(String text) throws Exception{
// 编码
String encode = Base64.getEncoder().encodeToString(text.getBytes("UTF-8"));
System.out.println(encode);//6aKd5oiR6Zeu6Zeu6Zeu
return encode;
}
public static String decode(String text) throws Exception{
// 解码
byte[] decode = Base64.getDecoder().decode(text);
return new String(decode, "UTF-8");
}
}