mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-01 04:57:07 +08:00
新增:新增修改密码功能,并优化部分以往代码
This commit is contained in:
@@ -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}$";
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私钥解密
|
||||
*
|
||||
|
Reference in New Issue
Block a user