Browse Source

//加盐和胡椒粉

private_deployment
xhxu 2 years ago
parent
commit
1729f6f572
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      suimangService/src/main/java/com/iformall/utils/PasswordHelper.java

+ 2
- 1
suimangService/src/main/java/com/iformall/utils/PasswordHelper.java View File

@@ -10,6 +10,7 @@ public class PasswordHelper {
//private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
private String algorithmName = "md5";
private int hashIterations = 2;
private String salt = "salt and pepper";

public void encryptPassword(MallUserInfo user) {
//String salt=randomNumberGenerator.nextBytes().toHex();
@@ -24,7 +25,7 @@ public class PasswordHelper {
}

public String encryptPassword(String password) {
return new SimpleHash(algorithmName, password, hashIterations).toHex();
return new SimpleHash(algorithmName, password, ByteSource.Util.bytes(salt), hashIterations).toHex();
}




Loading…
Cancel
Save