public class PasswordUtil extends Object
加密工具
| 构造器和说明 |
|---|
PasswordUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
encodePassword(String password,
String salt)
SHA1算法一次hash进行编码
|
static String |
encodePassword(String password,
String salt,
int iterations)
通过SHA1对密码进行编码
|
static boolean |
isValidPassword(String password,
String hashedPassword,
String salt)
校验密码是否一致
|
public static boolean isValidPassword(String password, String hashedPassword, String salt) throws NoSuchAlgorithmException
password: - 前端传过来的加密密码hashedPassword:数据库中储存加密过后的密码 - salt:盐值 - NoSuchAlgorithmExceptionpublic static String encodePassword(String password, String salt, int iterations) throws NoSuchAlgorithmException
password:密码 - salt:盐值 - iterations - hash次数,如果小于1,则默认设置为1次NoSuchAlgorithmExceptionpublic static String encodePassword(String password, String salt) throws NoSuchAlgorithmException
password - 密码salt - 盐NoSuchAlgorithmExceptionCopyright © 2022. All rights reserved.