refactor(open): 重构及优化应用管理代码

This commit is contained in:
2024-11-17 22:18:02 +08:00
parent 3116836b01
commit d1b38242b9
15 changed files with 313 additions and 308 deletions

View File

@@ -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));
}
/**
* 私钥解密
*