简体   繁体   中英

Hashing passwords in Java servlet

I earlier found this answer regarding hashing passwords in Java, but I'm using Java 7 while the answer works only in Java 8. I tried to adapt it without success, so... Any suggestions? I also downloaded the bouncycastle library, but I don't understand how it works...

Thank you for your time

I would suggest using Jasypt it very simple to use.

For example :

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM