在命令行中执行如下命令:
java -cp druid-1.0.16.jar com.alibaba.druid.filter.config.ConfigTools testpw
输出
privateKey:MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAp0Uml1u17Pr+qIEYzdzXg8nw4r2Wo+fQZbOxIkd6EnCRbkv6neQ8Ajm9XhSlJtcDRLAiF0JOvh/g9pWcjBd3lwIDAQABAkBNeFB8T4R9wm3JeykSx1KlfhTr3uTy+r1hLQ1AFByshufiS8TbUm0JCJgjdK7KE5HKeSuuv/6mZk6xF208kLDBAiEA4Wd0bTTpz9dFAavPaBIUk+XCKVNAjNXtwqwCG4EmjbcCIQC9+Zp4raVt3huP8sR5JpYOU+o773hwSXdtzfhMEXplIQIhAMrF8/IucMyeHyEiu+ImqcZnIiVlFKPd7Bd+ACNYKyO/AiAZvOpntSb3hqL3Uq25uDeWQ1o1upD3rYxnrQMZ0zhg4QIhAJN8XxM7FJRz82MGK70h4WFJqXTSlH5ztr06iAVDI/ug
publicKey:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKdFJpdbtez6/qiBGM3c14PJ8OK9lqPn0GWzsSJHehJwkW5L+p3kPAI5vV4UpSbXA0SwIhdCTr4f4PaVnIwXd5cCAwEAAQ==
password:FYlUzguXyxMln0h9uyVNA3EU2il1fc/MPzJiAbp5BH7LZGiQMs+Vp4KnLVF4zAAh4x9kPAS/IIqL/imuDuqYCA==
Druid中的ConfigTolls可以解析
import com.alibaba.druid.filter.config.ConfigTools;
public class testDruidPassword{
public static void test() throws Exception {
String publickey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKdFJpdbtez6/qiBGM3c14PJ8OK9lqPn0GWzsSJHehJwkW5L+p3kPAI5vV4UpSbXA0SwIhdCTr4f4PaVnIwXd5cCAwEAAQ==";
String password = "FYlUzguXyxMln0h9uyVNA3EU2il1fc/MPzJiAbp5BH7LZGiQMs+Vp4KnLVF4zAAh4x9kPAS/IIqL/imuDuqYCA==";
System.out.println( ConfigTools.decrypt(publickey, password) );
String pw = ConfigTools.encrypt("testpw");
System.out.println(pw);
System.out.println(pw.equals(password));
}
public static void main(String[] args) throws Exception {
test();
}
}