
原文:https://blog.csdn.net/gs12software/article/details/83899389
对称式加密:就是加密和解密都是使用同一个密钥,如DES加密
非对称式加密:[私钥,公钥],公钥与私钥是一对,如果用公钥对数据进行加密,只有用对应的私钥才能解密。如RSA加密
public static void main(String[] args) throws Exception {
//服务端和客户端的同一密钥
String secretKey = "39e828f83df9d909a8c87cb8d9ad599";
//加密
System.out.println(DesUtil.encryption("密码", secretKey));
//解密
String secretData = "被加密后的密码";
System.out.println(DesUtil.decryption(secretData, secretKey));
}