接口加密优化

v1.4.1
Parker 4 years ago
parent 98b4c1e684
commit c7ecad94e4

@ -149,4 +149,14 @@ public interface OtherCryptoAsymmetricRestApi {
@GetMapping("/getByCryptoType")
ResultVo<OtherCryptoAsymmetricModel> getByCryptoType(String optionCode);
// ===================
/**
*
* @param model
* @return ResultVo
*/
ResultVo<?> insertInner(@RequestBody OtherCryptoAsymmetricModel model);
}

@ -18,10 +18,10 @@ public enum CryptoAsymmetricType {
private final String code;
private final String desc;
public static CryptoAsymmetricType getCacheType(String cacheType) {
public static CryptoAsymmetricType getCryptoType(String code) {
CryptoAsymmetricType[] var1 = values();
for (CryptoAsymmetricType type : var1) {
if (type.code.equalsIgnoreCase(cacheType)) {
if (type.code.equalsIgnoreCase(code)) {
return type;
}
}
@ -42,4 +42,4 @@ public enum CryptoAsymmetricType {
this.code = code;
this.desc = desc;
}
}
}

@ -18,9 +18,7 @@ package org.opsli.core.filters.aspect;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.TypeUtil;
import cn.hutool.crypto.asymmetric.RSA;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@ -29,11 +27,14 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.opsli.api.base.encrypt.BaseEncrypt;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.options.OptionsModel;
import org.opsli.common.annotation.InterfaceCrypto;
import org.opsli.common.enums.CryptoAsymmetricType;
import org.opsli.common.enums.OptionsType;
import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.Props;
import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.EncryptAndDecryptByRsaUtil;
import org.opsli.core.utils.CryptoAsymmetricUtil;
import org.opsli.core.utils.OptionsUtil;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@ -54,47 +55,7 @@ import static org.opsli.common.constants.OrderConstants.ENCRYPT_ADN_DECRYPT_AOP_
@Order(ENCRYPT_ADN_DECRYPT_AOP_SORT)
@Aspect
@Component
public class InterfaceEncryptAndDecryptAop {
/** RSA 公钥 */
private static String RSA_PUBLIC_KEY;
/** RSA 私钥 */
private static String RSA_PRIVATE_KEY;
/** RSA */
private static RSA ASSIGN_RSA;
static {
// 缓存前缀
Props props = new Props("application.yaml");
RSA_PUBLIC_KEY = props.getStr("opsli.encrypt-decrypt.rsa.public-key");
RSA_PRIVATE_KEY = props.getStr("opsli.encrypt-decrypt.rsa.private-key");
try {
ASSIGN_RSA = EncryptAndDecryptByRsaUtil.INSTANCE.createRsa(RSA_PUBLIC_KEY, RSA_PRIVATE_KEY);
}catch (Exception e){
ASSIGN_RSA = EncryptAndDecryptByRsaUtil.INSTANCE.createRsa();
RSA_PUBLIC_KEY = ASSIGN_RSA.getPublicKeyBase64();
RSA_PRIVATE_KEY = ASSIGN_RSA.getPrivateKeyBase64();
String errorMsg = StrUtil.format(CoreMsg.OTHER_EXCEPTION_RSA_CREATE.getMessage(),
RSA_PUBLIC_KEY, RSA_PRIVATE_KEY
);
log.error(errorMsg);
}
}
/**
*
* @return
*/
public static String getRsaPublicKey() {
return RSA_PUBLIC_KEY;
}
/**
*
* @return
*/
public static String getRsaPrivateKey() {
return RSA_PRIVATE_KEY;
}
public class InterfaceCryptoAop {
@Pointcut("@annotation(org.opsli.common.annotation.InterfaceCrypto)")
public void encryptAndDecrypt() {
@ -109,7 +70,16 @@ public class InterfaceEncryptAndDecryptAop {
// 获得请求参数
Object[] args = point.getArgs();
// 返回结果
Object returnValue = null;
Object returnValue;
// 获得系统配置参数 非对称加密枚举
CryptoAsymmetricType asymmetricType = null;
OptionsModel optionsModel = OptionsUtil.getOptionByCode(OptionsType.CRYPTO_ASYMMETRIC);
if(optionsModel != null){
// 获得加密类型
asymmetricType = CryptoAsymmetricType.getCryptoType(
optionsModel.getOptionValue());
}
MethodSignature signature = (MethodSignature) point.getSignature();
// 获得 方法
@ -117,7 +87,7 @@ public class InterfaceEncryptAndDecryptAop {
// 获得方法注解
InterfaceCrypto annotation =
method.getAnnotation(InterfaceCrypto.class);
if(annotation != null){
if(asymmetricType != null && annotation != null){
// 1. 拆解请求数据
// request 解密
@ -130,7 +100,7 @@ public class InterfaceEncryptAndDecryptAop {
BaseEncrypt baseEncrypt = (BaseEncrypt) arg;
String encryptData = baseEncrypt.getEncryptData();
// 解密对象
Object dataToObj = EncryptAndDecryptByRsaUtil.INSTANCE.decryptedDataToObj(ASSIGN_RSA, encryptData);
Object dataToObj = CryptoAsymmetricUtil.decryptToObj(asymmetricType, encryptData);
// 根据方法类型转化对象
Type type = TypeUtil.getParamType(method, i);
@ -160,28 +130,33 @@ public class InterfaceEncryptAndDecryptAop {
// 3. 返回响应数据
// response 加密
if (annotation.enable() && annotation.responseEncrypt()){
try {
// 执行加密过程
if(returnValue instanceof ResultVo){
ResultVo<Object> ret = (ResultVo<Object>) returnValue;
ret.setData(
EncryptAndDecryptByRsaUtil.INSTANCE.encryptedData(
ASSIGN_RSA, ret.getData()
)
);
returnValue = ret;
}else {
returnValue = EncryptAndDecryptByRsaUtil.INSTANCE.encryptedData(
ASSIGN_RSA, returnValue
);
if(returnValue != null){
try {
// 执行加密过程
if(returnValue instanceof ResultVo){
ResultVo<Object> ret = (ResultVo<Object>) returnValue;
ret.setData(
CryptoAsymmetricUtil.encrypt(asymmetricType, ret.getData())
);
returnValue = ret;
}else {
returnValue = CryptoAsymmetricUtil.encrypt(asymmetricType, returnValue);
}
}catch (Exception e){
// RSA非对称加密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_EN);
}
}catch (Exception e){
// RSA非对称加密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_EN);
}
}
return returnValue;
}else{
returnValue = point.proceed(args);
}
return returnValue;
}
// ===============================
}

@ -64,6 +64,10 @@ public enum CoreMsg implements BaseMsg {
/** 其他 */
OTHER_EXCEPTION_LIMITER(10700,"当前系统繁忙,请稍后再试"),
OTHER_EXCEPTION_CRYPTO_EN(10702,"加密失败"),
OTHER_EXCEPTION_CRYPTO_DE(10703,"解密失败"),
OTHER_EXCEPTION_CRYPTO_REFLEX(10703,"解密反射失败"),
OTHER_EXCEPTION_RSA_CREATE(10701,"指定RSA算法器创建失败系统已自动创建随机RSA算法\n公钥{}\n私钥{}"),
OTHER_EXCEPTION_RSA_EN(10702,"RSA非对称加密失败"),
OTHER_EXCEPTION_RSA_DE(10703,"RSA非对称解密失败"),

@ -28,8 +28,10 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.web.system.other.crypto.OtherCryptoAsymmetricRestApi;
import org.opsli.api.wrapper.system.options.OptionsModel;
import org.opsli.api.wrapper.system.other.crypto.OtherCryptoAsymmetricModel;
import org.opsli.common.enums.CryptoAsymmetricType;
import org.opsli.common.enums.OptionsType;
import org.opsli.common.exception.ServiceException;
import org.opsli.core.cache.local.CacheUtil;
import org.opsli.core.msg.CoreMsg;
@ -66,8 +68,8 @@ public class CryptoAsymmetricUtil {
/**
* cryptoAsymmetricType
* @param cryptoAsymmetricType
* @return
* @param cryptoAsymmetricType type
* @return model
*/
public static OtherCryptoAsymmetricModel getCryptoAsymmetric(final CryptoAsymmetricType cryptoAsymmetricType){
if(cryptoAsymmetricType == null){
@ -106,12 +108,36 @@ public class CryptoAsymmetricUtil {
return model;
}
boolean noData = true;
// 查询数据库
ResultVo<OtherCryptoAsymmetricModel> resultVo = otherCryptoAsymmetricRestApi.getByCryptoType(typeCode);
if(resultVo.isSuccess()){
model = resultVo.getData();
// 存入缓存
CacheUtil.put(cacheKey, model);
if(model != null){
noData = false;
// 存入缓存
CacheUtil.put(cacheKey, model);
}
}
// 如果没取到数值 则自动创建
if(noData){
// 获得系统配置参数 非对称加密枚举
CryptoAsymmetricType asymmetricType = null;
OptionsModel optionsModel = OptionsUtil.getOptionByCode(OptionsType.CRYPTO_ASYMMETRIC);
if(optionsModel != null){
// 获得加密类型
asymmetricType = CryptoAsymmetricType.getCryptoType(
optionsModel.getOptionValue());
}
// 默认 RSA 算法
model = create(asymmetricType!=null?asymmetricType:CryptoAsymmetricType.RSA);
ResultVo<?> insertModel = otherCryptoAsymmetricRestApi.insertInner(model);
if(insertModel.isSuccess()){
// 存入缓存
CacheUtil.put(cacheKey, model);
}
}
}catch (Exception e){
log.error(e.getMessage(),e);
@ -134,8 +160,8 @@ public class CryptoAsymmetricUtil {
/**
* -
* @param model
* @return
* @param model m
* @return boolean
*/
public static boolean refresh(final OtherCryptoAsymmetricModel model){
if(model == null || StringUtils.isEmpty(model.getCryptoType())){
@ -174,10 +200,11 @@ public class CryptoAsymmetricUtil {
/**
*
* @param cryptoAsymmetricType
* @return
* @return Model
*/
public static OtherCryptoAsymmetricModel create(final CryptoAsymmetricType cryptoAsymmetricType){
OtherCryptoAsymmetricModel model = new OtherCryptoAsymmetricModel();
model.setCryptoType(cryptoAsymmetricType.getCode());
switch (cryptoAsymmetricType){
case RSA:
RSA rsa = SecureUtil.rsa();
@ -204,7 +231,8 @@ public class CryptoAsymmetricUtil {
/**
*
* @param cryptoAsymmetricType
* @return
* @param data
* @return String
*/
public static String encrypt(final CryptoAsymmetricType cryptoAsymmetricType, final Object data){
@ -214,14 +242,15 @@ public class CryptoAsymmetricUtil {
// 原始/加密 数据
String encryptedStr = jsonObject.toString();
OtherCryptoAsymmetricModel cryptoAsymmetric = getCryptoAsymmetric(cryptoAsymmetricType);
// 如果找不到 公私钥 直接返回原始数据
if(cryptoAsymmetric == null){
return encryptedStr;
}
try {
OtherCryptoAsymmetricModel cryptoAsymmetric = getCryptoAsymmetric(cryptoAsymmetricType);
// 如果找不到 公私钥 直接返回原始数据
if(cryptoAsymmetric == null){
throw new RuntimeException();
}
switch (cryptoAsymmetricType){
case RSA:
RSA rsa = SecureUtil.rsa(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
@ -239,120 +268,93 @@ public class CryptoAsymmetricUtil {
StrUtil.bytes(encryptedStr, CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
break;
default:
break;
throw new RuntimeException();
}
}catch (Exception e){
// 加密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_EN);
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_CRYPTO_EN);
}
return encryptedStr;
}
/**
*
* RSA
* @param cryptoAsymmetricType
* @return
* @param data
* @return Object
*/
public static String decrypt(final CryptoAsymmetricType cryptoAsymmetricType, final String data){
if(StringUtils.isEmpty(data)){
return null;
}
OtherCryptoAsymmetricModel cryptoAsymmetric = getCryptoAsymmetric(cryptoAsymmetricType);
// 如果找不到 公私钥 直接返回原始数据
if(cryptoAsymmetric == null){
return data;
public static Object decryptToObj(final CryptoAsymmetricType cryptoAsymmetricType, final String data){
Object obj;
String decryptedData = decrypt(cryptoAsymmetricType, data);
try{
obj = JSONObject.parse(decryptedData);
}catch (Exception e){
// 非对称解密反射失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_CRYPTO_REFLEX);
}
return obj;
}
/**
*
* @param cryptoAsymmetricType
* @param data
* @return String
*/
public static String decrypt(final CryptoAsymmetricType cryptoAsymmetricType, final String data){
String decryptStr;
try {
if(StringUtils.isEmpty(data)){
throw new RuntimeException();
}
OtherCryptoAsymmetricModel cryptoAsymmetric = getCryptoAsymmetric(cryptoAsymmetricType);
// 如果找不到 公私钥 直接返回原始数据
if(cryptoAsymmetric == null){
throw new RuntimeException();
}
String tmp;
String currData = data.replaceAll(" ", "+");
switch (cryptoAsymmetricType){
case RSA:
RSA rsa = SecureUtil.rsa(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
decryptStr = rsa.decryptStr(data, KeyType.PrivateKey);
tmp = rsa.decryptStr(currData, KeyType.PrivateKey);
break;
case SM2:
SM2 sm2 = SmUtil.sm2(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
decryptStr = sm2.decryptStr(data, KeyType.PrivateKey);
tmp = sm2.decryptStr(currData, KeyType.PrivateKey);
break;
case ECIES:
ECIES ecies = new ECIES(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
decryptStr = ecies.decryptStr(data, KeyType.PrivateKey);
tmp = ecies.decryptStr(currData, KeyType.PrivateKey);
break;
default:
break;
throw new RuntimeException();
}
}catch (Exception e){
// 加密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_EN);
}
//解密,因为编码传值时有空格出现
String decryptStr;
try{
String tmp = rsa.decryptStr(data, KeyType.PrivateKey);
// 转换对象
JSONObject jsonObject = JSONObject.parseObject(tmp);
Object obj = jsonObject.get(rsaKey);
Object obj = jsonObject.get(CRYPTO_KEY);
if(obj instanceof Collection){
decryptStr = jsonObject.getJSONArray(rsaKey).toJSONString();
decryptStr = jsonObject.getJSONArray(CRYPTO_KEY).toJSONString();
}else{
decryptStr = jsonObject.getJSONObject(rsaKey).toJSONString();
decryptStr = jsonObject.getJSONObject(CRYPTO_KEY).toJSONString();
}
}catch (Exception e){
// 解密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_DE);
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_CRYPTO_DE);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put(CRYPTO_KEY, data);
// 原始/加密 数据
String encryptedStr = jsonObject.toString();
OtherCryptoAsymmetricModel cryptoAsymmetric = getCryptoAsymmetric(cryptoAsymmetricType);
// 如果找不到 公私钥 直接返回原始数据
if(cryptoAsymmetric == null){
return encryptedStr;
}
try {
switch (cryptoAsymmetricType){
case RSA:
RSA rsa = SecureUtil.rsa(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
encryptedStr = rsa.encryptBase64(
StrUtil.bytes(encryptedStr, CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
break;
case SM2:
SM2 sm2 = SmUtil.sm2(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
encryptedStr = sm2.encryptBase64(
StrUtil.bytes(encryptedStr, CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
break;
case ECIES:
ECIES ecies = new ECIES(cryptoAsymmetric.getPrivateKey(), cryptoAsymmetric.getPublicKey());
encryptedStr = ecies.encryptBase64(
StrUtil.bytes(encryptedStr, CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
break;
default:
break;
}
}catch (Exception e){
// 加密失败
throw new ServiceException(CoreMsg.OTHER_EXCEPTION_RSA_EN);
}
return encryptedStr;
return decryptStr;
}
// =====================================
@Autowired
public static void setOtherCryptoAsymmetricRestApi(OtherCryptoAsymmetricRestApi otherCryptoAsymmetricRestApi) {
public void setOtherCryptoAsymmetricRestApi(OtherCryptoAsymmetricRestApi otherCryptoAsymmetricRestApi) {
CryptoAsymmetricUtil.otherCryptoAsymmetricRestApi = otherCryptoAsymmetricRestApi;
}

@ -21,6 +21,10 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.system.options.OptionsModel;
import org.opsli.api.wrapper.system.other.crypto.OtherCryptoAsymmetricModel;
import org.opsli.common.enums.CryptoAsymmetricType;
import org.opsli.common.enums.OptionsType;
import org.opsli.core.utils.ValidationUtil;
import org.opsli.api.wrapper.system.tenant.TenantModel;
import org.opsli.api.wrapper.system.user.UserModel;
@ -31,7 +35,7 @@ import org.opsli.common.enums.AlertType;
import org.opsli.common.exception.TokenException;
import org.opsli.common.thread.refuse.AsyncProcessQueueReFuse;
import org.opsli.common.utils.IPUtil;
import org.opsli.core.filters.aspect.InterfaceEncryptAndDecryptAop;
import org.opsli.core.filters.aspect.InterfaceCryptoAop;
import org.opsli.core.msg.TokenMsg;
import org.opsli.core.security.shiro.realm.JwtRealm;
import org.opsli.core.utils.*;
@ -196,10 +200,24 @@ public class LoginRestController {
@ApiOperation(value = "获得公钥", notes = "获得公钥")
@GetMapping("/sys/publicKey")
public ResultVo<?> getPublicKey(){
return ResultVo.success(
"操作成功!",
InterfaceEncryptAndDecryptAop.getRsaPublicKey()
);
// 获得系统配置参数
OptionsModel optionsModel = OptionsUtil.getOptionByCode(OptionsType.CRYPTO_ASYMMETRIC);
if(optionsModel != null){
// 获得加密类型
CryptoAsymmetricType cryptoType = CryptoAsymmetricType.getCryptoType(
optionsModel.getOptionValue());
OtherCryptoAsymmetricModel cryptoAsymmetric = CryptoAsymmetricUtil.getCryptoAsymmetric(cryptoType);
if(cryptoAsymmetric != null){
return ResultVo.success(
"操作成功!",
cryptoAsymmetric.getPublicKey()
);
}
}
// 失败
return ResultVo.error();
}
// =================

@ -21,8 +21,11 @@ import java.util.Date;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.opsli.core.base.entity.BaseEntity;
/**
@ -49,4 +52,35 @@ public class OtherCryptoAsymmetric extends BaseEntity {
// ========================================
/** 创建人 */
@JsonIgnore
@Setter(AccessLevel.NONE)
@TableField(exist = false)
private String createBy;
/** 创建时间 */
@JsonIgnore
@Setter(AccessLevel.NONE)
@TableField(exist = false)
private Date createTime;
/** 更新人 */
@JsonIgnore
@Setter(AccessLevel.NONE)
@TableField(exist = false)
private String updateBy;
/** 更新时间 */
@JsonIgnore
@Setter(AccessLevel.NONE)
@TableField(exist = false)
private Date updateTime;
/** 乐观锁 版本 */
@JsonIgnore
@Setter(AccessLevel.NONE)
@TableField(exist = false)
private Integer version;
}

@ -18,6 +18,7 @@ package org.opsli.modulars.system.other.crypto.service;
import org.opsli.api.wrapper.system.other.crypto.OtherCryptoAsymmetricModel;
import org.opsli.common.enums.CryptoAsymmetricType;
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
@ -34,4 +35,11 @@ import org.opsli.modulars.system.other.crypto.entity.OtherCryptoAsymmetric;
*/
public interface IOtherCryptoAsymmetricService extends CrudServiceInterface<OtherCryptoAsymmetric, OtherCryptoAsymmetricModel> {
/***
*
* @param type
* @return OtherCryptoAsymmetricModel
*/
OtherCryptoAsymmetricModel reset(CryptoAsymmetricType type);
}

@ -72,44 +72,21 @@ public class OtherCryptoAsymmetricServiceImpl extends CrudServiceImpl<OtherCrypt
return super.insert(model);
}
/***
*
* @param cryptoAsymmetricType
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public OtherCryptoAsymmetricModel reset(CryptoAsymmetricType cryptoAsymmetricType) {
if(cryptoAsymmetricType == null){
@Transactional(rollbackFor = Exception.class)
public OtherCryptoAsymmetricModel update(OtherCryptoAsymmetricModel model) {
if(model == null){
return null;
}
// 唯一验证
OtherCryptoAsymmetricModel model = new OtherCryptoAsymmetricModel();
model.setCryptoType(cryptoAsymmetricType.getCode());
Integer count = this.uniqueVerificationByCode(model);
// 修改
if(count > 0){
}
// 新增
if(count != null && count > 0){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_OTHER_CRYPTO_UNIQUE);
}
model = super.update(model);
if(model != null){
// 清除缓存
this.clearCache(Collections.singletonList(model));
}
return model;
return super.update(model);
}
@Override
@ -140,6 +117,31 @@ public class OtherCryptoAsymmetricServiceImpl extends CrudServiceImpl<OtherCrypt
return super.deleteAll(ids);
}
/***
*
* @param type
* @return OtherCryptoAsymmetricModel
*/
@Transactional(rollbackFor = Exception.class)
@Override
public OtherCryptoAsymmetricModel reset(CryptoAsymmetricType type) {
if(type == null){
return null;
}
QueryWrapper<OtherCryptoAsymmetric> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("crypto_type", type.getCode());
OtherCryptoAsymmetricModel model = super.transformT2M(
this.getOne(queryWrapper)
);
// 删除当前数据 并清空缓存
this.delete(model);
// 重新获得缓存 如果当前库中没有该缓存 则自动创建
return CryptoAsymmetricUtil.getCryptoAsymmetric(type);
}
// =======================
/**

@ -229,4 +229,11 @@ public class OtherCryptoAsymmetricRestController extends BaseRestController<Othe
WrapperUtil.transformInstance(entity, OtherCryptoAsymmetricModel.class)
);
}
@Override
public ResultVo<?> insertInner(OtherCryptoAsymmetricModel model) {
// 调用新增方法
IService.insert(model);
return ResultVo.success("新增非对称加密成功");
}
}

@ -215,26 +215,3 @@ opsli:
import-max-count: 20000
# Excel 最大导出操作数量 防止OOM
export-max-count: 20000
#加解密
encrypt-decrypt:
enable: rsa
# RSA 加密算法
rsa:
# 公钥
public-key: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCakyyq8rfkmKvKB2fz3hUeuD6tgParCmZmRc1OoL5EN+yXghQmDIrcZhewLZZLUpLQd3T3cRxKaW30nWNfoteNHgKjGYGu4+BZoyHZ8ltTmrolYGopiSwBMhO7kwAD4IK1PZHaoF2wPISH35ubbugykav7dTaWBDuNkvyBiv8qMQIDAQAB"
# 私钥
private-key: "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJqTLKryt+SYq8oHZ/PeFR64Pq2A9qsKZmZFzU6gvkQ37JeCFCYMitxmF7AtlktSktB3dPdxHEppbfSdY1+i140eAqMZga7j4FmjIdnyW1OauiVgaimJLAEyE7uTAAPggrU9kdqgXbA8hIffm5tu6DKRq/t1NpYEO42S/IGK/yoxAgMBAAECgYEAiWu+klwm0LxKPdpHuK7/58e1MVst8PHWB6aW2AhgHxX46NlkQE92RGsfNCnTLDPFAkCxZCrTE/SXJJmn9yY2qoS26OV0PbTGajk96M8lDi9JSmWCNV1eywPecObSyvtPd5jaPtq2jkgNY/hHJjH6kV7UAFZuaSK7jxskfq7uR2ECQQDPfmGjPiMc65+LE9U7jC4LokyUi1yCgN6AY5MgF6fkxUVJD2mtl9BqRK7qE0OnsRb0NzID3PSfa7aA2I0Rlsj/AkEAvrXUBQ6hfuEwD1896qpSJUr7tLidby/3jYwSoewuydDT2duDc2ZCz4/U/1NpxSxWT10ZZi2ExsFZn/3PDylczwJARA3oijkcHSUu69eybVh51bkCswnOasNHtwZxv+niWEdXhTH38EbFxcUHNaDh5MNRiwH7dobm+M7EShg8lJNHEwJAclRdU97OkFr9zeliHCGZd4P5XAFlWHfgJ7p2nR4Teqe3qZ6Aspj2qqpmnd7qxOrsn02H4YqeU+0sBs9I56T7XwJAAg8wHrh/FAPY96mAya0bpv6zm/7bave17vs+8B+fhBEHHuvetfv8Xi/RkXL0rjE4LaTHefoUbZPNbIhNYiN0CQ=="
# SM2 加密算法
sm2:
# 公钥
public-key: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCakyyq8rfkmKvKB2fz3hUeuD6tgParCmZmRc1OoL5EN+yXghQmDIrcZhewLZZLUpLQd3T3cRxKaW30nWNfoteNHgKjGYGu4+BZoyHZ8ltTmrolYGopiSwBMhO7kwAD4IK1PZHaoF2wPISH35ubbugykav7dTaWBDuNkvyBiv8qMQIDAQAB"
# 私钥
private-key: "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJqTLKryt+SYq8oHZ/PeFR64Pq2A9qsKZmZFzU6gvkQ37JeCFCYMitxmF7AtlktSktB3dPdxHEppbfSdY1+i140eAqMZga7j4FmjIdnyW1OauiVgaimJLAEyE7uTAAPggrU9kdqgXbA8hIffm5tu6DKRq/t1NpYEO42S/IGK/yoxAgMBAAECgYEAiWu+klwm0LxKPdpHuK7/58e1MVst8PHWB6aW2AhgHxX46NlkQE92RGsfNCnTLDPFAkCxZCrTE/SXJJmn9yY2qoS26OV0PbTGajk96M8lDi9JSmWCNV1eywPecObSyvtPd5jaPtq2jkgNY/hHJjH6kV7UAFZuaSK7jxskfq7uR2ECQQDPfmGjPiMc65+LE9U7jC4LokyUi1yCgN6AY5MgF6fkxUVJD2mtl9BqRK7qE0OnsRb0NzID3PSfa7aA2I0Rlsj/AkEAvrXUBQ6hfuEwD1896qpSJUr7tLidby/3jYwSoewuydDT2duDc2ZCz4/U/1NpxSxWT10ZZi2ExsFZn/3PDylczwJARA3oijkcHSUu69eybVh51bkCswnOasNHtwZxv+niWEdXhTH38EbFxcUHNaDh5MNRiwH7dobm+M7EShg8lJNHEwJAclRdU97OkFr9zeliHCGZd4P5XAFlWHfgJ7p2nR4Teqe3qZ6Aspj2qqpmnd7qxOrsn02H4YqeU+0sBs9I56T7XwJAAg8wHrh/FAPY96mAya0bpv6zm/7bave17vs+8B+fhBEHHuvetfv8Xi/RkXL0rjE4LaTHefoUbZPNbIhNYiN0CQ=="

Loading…
Cancel
Save