我读过这里和这里,与其使用胡椒,不如在存储到数据库之前对散列/盐渍密码进行加密。尤其是使用Java,因为没有盐分/胡椒库,而只是用于盐分散列,而且我也不会以任何方式实现自己的密码。对此有疑问:
我现在用来获取散列的代码示例:
KeySpec ks = new PBEKeySpec(password, salt, 10, 512);
SecretKeyFactory kf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512");
SecretKey sk = kf.generateSecret(ks);
byte[] hash = sk.getEncoded();我要添加一个代码:
Cipher cipher=Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
byte [] encryptedHash=cipher.doFinal(hash);发布于 2020-08-11 13:08:20
hashPassword(thePassword, theSalt)替换代码hashPassword(thePassword, the128bitRandomPepper + theSalt)。+是Java中的字符串连接操作符。要回答您引用的两个链接中的声明:
https://security.stackexchange.com/questions/236924
复制相似问题