具有 Spring 安全性的密码散列

Password hashing with Spring Security

是否可以使用 Spring Security BCryptPasswordEncoder 为密码添加额外的盐分?

您不能将 Bcrypt 算法与自定义盐一起使用,因为在 bcrypt algorithm it always chooses a random salt to encode the password and and then finally it attaches the salt to the encoded password. 这是它的工作原理,这就是您不能在此算法中使用自己的自定义盐的原因。

即使您收到的错误消息也显示相同的内容。如果您想使用自定义盐源进行加密,您应该改用 SHA-256 或 MD5 算法。