xiangpei
2024-03-28 0f431b52e0936456bd165d9553761bfd8a5a0517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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();
    }
 
}