代码:
public static void main(String[] args) {
String str = "abc123456";
String asB64 = new String(Base64.encodeBase64(str.getBytes()));//加密
System.out.println(asB64);
String str2 = new String(Base64.decodeBase64(asB64.getBytes()));//解密
System.out.println(str2);
}
输出如下:
YWJjMTIzNDU2
abc123456
Process finished with exit code 0