Java进行Base64的编码(Encode)与解码(Decode)
2021-04-12 06:26
标签:void import 字符串 pwd cep system ted 解密 tostring Java进行Base64的编码(Encode)与解码(Decode) 标签:void import 字符串 pwd cep system ted 解密 tostring 原文地址:https://blog.51cto.com/12012821/2512109import java.util.Base64;
public class Test {
public static void main(String[] args) throws UnsupportedEncodingException {
// 要加密的字符串
String pwd = "12345678";
// 加密
String encodeToString = Base64.getEncoder().encodeToString(pwd.getBytes("UTF-8"));
System.out.println(encodeToString);// MTIzNDU2Nzg=
// 解密
String decodeToString = new String(Base64.getDecoder().decode(encodeToString.getBytes()), "UTF-8");
System.out.println(decodeToString);// 12345678
}
}
文章标题:Java进行Base64的编码(Encode)与解码(Decode)
文章链接:http://soscw.com/index.php/essay/74593.html