publish 2.0.3

This commit is contained in:
曾文豪
2024-09-10 11:08:06 +08:00
parent 02c2ccc0ff
commit d6ed2b8037
13 changed files with 42 additions and 43 deletions

View File

@@ -28,6 +28,7 @@ public class EncryptConfig {
private String key = "WmdUzPJXbngVNiaSsQrihg==";
private Integer saltSize = 8;
private boolean body = false;
private String pwdPatten = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
@@ -73,25 +74,13 @@ public class EncryptConfig {
if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
salt = RandomUtil.randomString(saltSize);
}
if (!passwdComplexity(inputPasswd)) {
throw new ApiException("需要包含数字、大小写字母、特殊符号且长度不低于8位");
if (!inputPasswd.matches(getPwdPatten())) {
throw new ApiException("密码复杂度不够,请重新设置");
}
return encrypt(salt + SecureUtil.sha1(salt + inputPasswd));
}
/**
* 复杂度校验
*
* @param inputPasswd
* @return
*/
public boolean passwdComplexity(String inputPasswd) {
String password = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
return inputPasswd.matches(password);
}
/**
* 密码校验
*
@@ -133,4 +122,12 @@ public class EncryptConfig {
public void setBody(boolean body) {
this.body = body;
}
public String getPwdPatten() {
return pwdPatten;
}
public void setPwdPatten(String pwdPatten) {
this.pwdPatten = pwdPatten;
}
}