时间:2021-07-01 10:21:17 帮助过:3人阅读
package com.t1; import com.alibaba.druid.filter.config.ConfigTools; public class DruidTest { public static void main(String[] args) throws Exception { //密码明文 String password = "12345"; System.out.println("密码[ "+password+" ]的加密信息如下:\n"); String [] keyPair = ConfigTools.genKeyPair(512); //私钥 String privateKey = keyPair[0]; //公钥 String publicKey = keyPair[1]; //用私钥加密后的密文 password = ConfigTools.encrypt(privateKey, password); System.out.println("privateKey:"+privateKey); System.out.println("publicKey:"+publicKey); System.out.println("password:"+password); String decryptPassword=ConfigTools.decrypt(publicKey, password);
System.out.println("decryptPassword:"+decryptPassword); } }
Druid 数据库用户密码加密 代码实现
标签: