init
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.tailbet.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 密码工具类
|
||||
*/
|
||||
@Component
|
||||
public class PasswordUtil {
|
||||
|
||||
/**
|
||||
* BCrypt加密
|
||||
*/
|
||||
public String encode(String rawPassword) {
|
||||
return DigestUtil.bcrypt(rawPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* BCrypt校验
|
||||
*/
|
||||
public boolean matches(String rawPassword, String encodedPassword) {
|
||||
if (StrUtil.isBlank(rawPassword) || StrUtil.isBlank(encodedPassword)) {
|
||||
return false;
|
||||
}
|
||||
return DigestUtil.bcryptCheck(rawPassword, encodedPassword);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user