标签:void import 字符串 pwd cep system ted 解密 tostring
import 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)
标签:void import 字符串 pwd cep system ted 解密 tostring
原文地址:https://blog.51cto.com/12012821/2512109