Spring Security 提供了BCryptPasswordEncoder类,实现Spring的PasswordEncoder接口使用BCrypt强哈希方法来加密密码。
BCrypt强哈希方法 每次加密的结果都不一样。
加密
String BCryptPasswordEncoder.encode(String str)
传入明文与数据库密文准备进行验证
Boolean BCryptPasswordEncoder.matches(String rawPassword, String encodedPassword)
底层走BCrypt.checkpw()方法匹配 ↓ ↓ ↓
Boolean BCrypt.checkpw(String rawPassword, String encodedPassword)
本文介绍Spring Security中BCryptPasswordEncoder的使用方法,包括如何利用BCrypt强哈希技术加密密码,确保每次加密结果的独特性,以及如何验证明文与数据库中存储的密文是否匹配。

1万+

被折叠的 条评论
为什么被折叠?



