package com.mindskip.xzs.configuration.utility;
|
|
import cn.hutool.crypto.asymmetric.RSA;
|
import cn.hutool.crypto.digest.MD5;
|
import com.mindskip.xzs.configuration.property.RsaProperty;
|
import com.mindskip.xzs.configuration.property.SystemConfig;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
|
/**
|
* @version 2.2.0
|
* @description: 加密公共类
|
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
|
* @date 2021 /9/7 9:45
|
*/
|
@Configuration
|
public class EncryptUtil {
|
|
private final SystemConfig systemConfig;
|
|
/**
|
* Instantiates a new Encrypt util.
|
*
|
* @param systemConfig the system config
|
*/
|
public EncryptUtil(SystemConfig systemConfig) {
|
this.systemConfig = systemConfig;
|
}
|
|
/**
|
* Login rsa rsa.
|
*
|
* @return the rsa
|
*/
|
@Bean("LoginRSA")
|
public RSA loginRSA() {
|
RsaProperty rsaProperty = systemConfig.getEncrypt().getLogin().getRsa();
|
return new RSA(rsaProperty.getPrivateKey(), rsaProperty.getPublicKey());
|
}
|
|
|
/**
|
* Database rsa rsa.
|
*
|
* @return the rsa
|
*/
|
@Bean("DatabaseRSA")
|
public RSA databaseRSA() {
|
RsaProperty rsaProperty = systemConfig.getEncrypt().getDatabase().getRsa();
|
return new RSA(rsaProperty.getPrivateKey(), rsaProperty.getPublicKey());
|
}
|
|
/**
|
* Question rsa rsa.
|
*
|
* @return the rsa
|
*/
|
@Bean("QuestionRSA")
|
public RSA questionRSA() {
|
RsaProperty rsaProperty = systemConfig.getEncrypt().getQuestion().getRsa();
|
return new RSA(rsaProperty.getPrivateKey(), rsaProperty.getPublicKey());
|
}
|
|
/**
|
* Md 5 md 5.
|
*
|
* @return the md 5
|
*/
|
@Bean
|
public MD5 md5() {
|
return new MD5();
|
}
|
|
}
|