String a = "ABCc";
System.out.println("原始密码="+a);
try {
//加密
byte[] bytes = a.getBytes("utf8");
String str = Base64.encodeBase64String(bytes);
System.out.println("加密后="+str);
//解密
byte[] bytes2 = str.getBytes("utf8");
byte[] decodeBase64 = Base64.decodeBase64(bytes2);
System.out.println("加密前="+new String(decodeBase64));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("原始密码="+a);
try {
//加密
byte[] bytes = a.getBytes("utf8");
String str = Base64.encodeBase64String(bytes);
System.out.println("加密后="+str);
//解密
byte[] bytes2 = str.getBytes("utf8");
byte[] decodeBase64 = Base64.decodeBase64(bytes2);
System.out.println("加密前="+new String(decodeBase64));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}