当前位置:主页 > 软件编程 > JAVA代码 >

java8版本base64加密解密的实例

时间:2021-12-31 09:08:23 | 栏目:JAVA代码 | 点击:

首先,先是加密,这里我使用了base64类

try {
String asB64 = Base64.getEncoder().encodeToString("http://www.baidu.com".getBytes("utf-8"));
System.out.println(asB64); 
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

其次是解密,

byte[] asBytes = Base64.getDecoder().decode(asB64); 
System.out.println(new String(asBytes, "utf-8"));

您可能感兴趣的文章:

相关文章