我之前发现this关于Java中哈希密码的答案,但我使用的是Java 7,而答案仅适用于Java 8。 我试图调整它没有成功,所以...任何建议? 我还下载了bouncycastle库,但我不明白它是如何工作的......
感谢您的时间
答案 0 :(得分:0)
我建议使用Jasypt它非常简单易用。
示例:
private static final String ENC_ALGORITHM = "PBEWithMD5AndDES";
...
StandardPBEStringEncryptor textEncryptor = new StandardPBEStringEncryptor();
textEncryptor.setAlgorithm(ENC_ALGORITHM);
textEncryptor.setPassword("MySuperSecretSeed"); // make sure this is stored somewhere safe like an ENV variable
String encryptedPassword = textEncryptor.encrypt("Password to be encrypted");