新增:新增修改密码功能,并优化部分以往代码

This commit is contained in:
2023-01-10 23:25:58 +08:00
parent 519124a3c7
commit a08fd7773e
14 changed files with 331 additions and 12 deletions

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.common.consts;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* @author Charles7c
* @since 2023/1/10 20:06
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RegExpConstants {
/**
* 密码正则必须包含字母和数字的组合可以使用特殊字符长度在6-32之间
*/
public static final String PASSWORD = "^(?=.*\\d)(?=.*[a-z]).{6,32}$";
}

View File

@@ -23,6 +23,9 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import top.charles7c.cnadmin.common.config.properties.RsaProperties;
import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
/**
* 加密/解密工具类
*
@@ -45,6 +48,19 @@ public class SecureUtils {
return Base64.encode(SecureUtil.rsa(null, publicKey).encrypt(data, KeyType.PublicKey));
}
/**
* 私钥解密
*
* @param data
* 要解密的内容Base64 加密过)
* @return 解密后的内容
*/
public static String decryptByRsaPrivateKey(String data) {
String privateKey = RsaProperties.PRIVATE_KEY;
ValidationUtils.exIfBlank(privateKey, "请配置 RSA 私钥");
return decryptByRsaPrivateKey(data, privateKey);
}
/**
* 私钥解密
*