mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 19:01:41 +08:00
refactor(open): 重构及优化应用管理代码
This commit is contained in:
@@ -26,6 +26,7 @@ import top.continew.starter.core.util.validate.ValidationUtils;
|
||||
import top.continew.starter.security.crypto.autoconfigure.CryptoProperties;
|
||||
import top.continew.starter.security.crypto.encryptor.AesEncryptor;
|
||||
import top.continew.starter.security.crypto.encryptor.IEncryptor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -40,6 +41,18 @@ public class SecureUtils {
|
||||
private SecureUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 公钥加密
|
||||
*
|
||||
* @param data 要加密的内容
|
||||
* @return 加密后的内容
|
||||
*/
|
||||
public static String encryptByRsaPublicKey(String data) {
|
||||
String publicKey = RsaProperties.PUBLIC_KEY;
|
||||
ValidationUtils.throwIfBlank(publicKey, "请配置 RSA 公钥");
|
||||
return encryptByRsaPublicKey(data, publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私钥解密
|
||||
*
|
||||
@@ -52,6 +65,17 @@ public class SecureUtils {
|
||||
return decryptByRsaPrivateKey(data, privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公钥加密
|
||||
*
|
||||
* @param data 要加密的内容
|
||||
* @param publicKey 公钥
|
||||
* @return 加密后的内容
|
||||
*/
|
||||
public static String encryptByRsaPublicKey(String data, String publicKey) {
|
||||
return new String(SecureUtil.rsa(null, publicKey).encrypt(data, KeyType.PublicKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 私钥解密
|
||||
*
|
||||
|
Reference in New Issue
Block a user