BASE64
一种较为简单的加密方式,效率较高,不能加密密码,可以加密图片或html文本等。
public static void base64(String str) {
byte[] bytes = str.getBytes();
//Base64 加密
String encoded = Base64.getEncoder().encodeToString(bytes);
System.out.println("Base 64 加密后:" + encoded);
//Base64 解密
byte[] decoded = Base64.getDecoder().decode(encoded);
String decodeStr = new String(decoded);
System.out.println("Base 64 解密后:" + decodeStr);
System.out.println();
}