赞
踩
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.2.8</version>
- </dependency>
在本地找到jar包所处目录,如:
打开cmd,定位到所在目录,执行指令:java -cp druid-1.0.26.jar com.alibaba.druid.filter.config.ConfigTools 你的密码(示例为password):
- Microsoft Windows [版本 6.3.9600]
- (c) 2013 Microsoft Corporation。保留所有权利。
-
- C:\Users\xiongfei>cd C:\Users\xiongfei\Desktop\5code\apache-maven-3.0.5\reposito
- ry\com\alibaba\druid\1.2.8
-
- C:\Users\xiongfei\Desktop\5code\apache-maven-3.0.5\repository\com\alibaba\druid\
- 1.2.8>java -cp druid-1.2.8.jar com.alibaba.druid.filter.config.ConfigTools passw
- ord
- privateKey:MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA6DYnu3t7Vs3GqFQRxxUgM
- +LJ/rVMs9g4KZPCexe/OWwx4EEDxoyFkzgwPJCSPfH+G2nrI9bG5EfuvwPz66pqHQIDAQABAkBrVLzAt
- 66mzK5KF7Gv51/fG7Bp/rrZVdN/xEBcTPmiPDLDnGWWuCbPWqV4plsoNO/izon447sdNau+IumxVt0BA
- iEA+yf8k2LY5atZfhBa5ktBPbjyC13/AhqxWf0HBkhEybECIQDssKJ48w0O0mRRQv7Gbc4PHfXShr/nH
- +ry1jbey8nWLQIhAJ8IMNy6qJC1MVOr04Mjf8ovg8RC3qhccpSCraICvNvhAiBRxrlr1nXVgCV+2gnSn
- w+Js41CPqJBBYsUeaSdl4VVxQIhALFGvS7CSpOb7tRzEj+jAcqlusofFnt++Aw0XVayl8yK
- publicKey:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOg2J7t7e1bNxqhUEccVIDPiyf61TLPYOCmTwn
- sXvzlsMeBBA8aMhZM4MDyQkj3x/htp6yPWxuRH7r8D8+uqah0CAwEAAQ==
- password:tFiGk4SsutR8olUK3+b2IVnZc0/WQYy+PBgWTxthYrGws1nB5YsvozG9narHb8iufx2+rlH
- nt4p4Y4TS6t32iA==
3、如果你想使用存在的密钥,可以通过如下方式得到加密后的密码:
- package test;
-
- import com.alibaba.druid.filter.config.ConfigTools;
- import com.alibaba.druid.util.DruidPasswordCallback;
-
-
- /**
- * @Description: Druid加解密(用一句话描述该文件做什么)
- * @author: qixiongfei
- * @date: 2022年4月11日 下午2:33:25
- * @version V1.0
- */
- public class DruidTest extends DruidPasswordCallback {
-
- public static void main(String[] args) throws Exception {
- String publickey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAO46RHV8MLaC0A1sw15q8dNxBurEmgHwFVP1AvA+3+2mKdDL4uzg7tlM1JdgTjV4QOQ79bs8ba1L4ao2I1vvFR8CAwEAAQ==";
- String password = "QImPIH1+jPtqz7fBEFWl3iXngrmbA8m+n/djyvWuE0OJQXOuvQPJGe8/BqLNn3NO7HioBWNX+XpjbgbaDNSJmw==";
- String pwd = ConfigTools.decrypt(publickey, password);
-
- System.out.println(pwd);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。