采用国密SM3加密算法,对系统密码进行加密
This commit is contained in:
parent
5ee366eab3
commit
b6a5c11764
|
@ -0,0 +1,23 @@
|
||||||
|
package net.maku.framework.security.crypto;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.SmUtil;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采用国密SM3加密算法,对系统密码进行加密
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
* <a href="https://maku.net">MAKU</a>
|
||||||
|
*/
|
||||||
|
public class Sm3PasswordEncoder implements PasswordEncoder {
|
||||||
|
@Override
|
||||||
|
public String encode(CharSequence rawPassword) {
|
||||||
|
return SmUtil.sm3(rawPassword.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
|
return StrUtil.equals(SmUtil.sm3(rawPassword.toString()), encodedPassword);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user