فهرست منبع

增加配置文件sm2加密

xusl 1 سال پیش
والد
کامیت
80de913541

+ 6 - 6
backend/pom.xml

@@ -160,12 +160,12 @@
             <artifactId>spring-boot-configuration-processor</artifactId>
             <optional>true</optional>
         </dependency>
-        <!--jasypt配置文件加解密-->
-        <dependency>
-            <groupId>com.github.ulisesbocchio</groupId>
-            <artifactId>jasypt-spring-boot-starter</artifactId>
-            <version>${jasypt-boot.version}</version>
-        </dependency>
+<!--        &lt;!&ndash;jasypt配置文件加解密&ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>com.github.ulisesbocchio</groupId>-->
+<!--            <artifactId>jasypt-spring-boot-starter</artifactId>-->
+<!--            <version>${jasypt-boot.version}</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>com.github.whvcse</groupId>
             <artifactId>easy-captcha</artifactId>

+ 2 - 2
backend/src/main/java/com/jiayue/ssi/SsiApplication.java

@@ -1,6 +1,6 @@
 package com.jiayue.ssi;
 
-import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
+//import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -14,7 +14,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
  */
 @SpringBootApplication
 @MapperScan("com.jiayue.ssi.mapper")
-@EnableEncryptableProperties
+//@EnableEncryptableProperties
 public class SsiApplication {
     public static void main(String[] args) {
         SpringApplication.run(SsiApplication.class, args);

+ 18 - 18
backend/src/main/java/com/jiayue/ssi/config/EncryptorConfig.java

@@ -1,10 +1,10 @@
 package com.jiayue.ssi.config;
 
-import org.jasypt.encryption.StringEncryptor;
-import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
-import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+//import org.jasypt.encryption.StringEncryptor;
+//import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
+//import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
 
 /**
 * jasypt配置类
@@ -12,18 +12,18 @@ import org.springframework.context.annotation.Configuration;
 * @author xsl
 * @since 2023/04/25
 */
-@Configuration
+//@Configuration
 public class EncryptorConfig {
-    @Bean("jasyptStringEncryptor")
-    public StringEncryptor jasyptStringEncryptor() {
-        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
-        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
-        config.setPassword("atpingan");
-        // 注释部分为配置默认
-        config.setAlgorithm("PBEWithMD5AndDES");
-        config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");
-        config.setPoolSize("1");
-        encryptor.setConfig(config);
-        return encryptor;
-    }
+//    @Bean("jasyptStringEncryptor")
+//    public StringEncryptor jasyptStringEncryptor() {
+//        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
+//        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
+//        config.setPassword("atpingan");
+//        // 注释部分为配置默认
+//        config.setAlgorithm("PBEWithMD5AndDES");
+//        config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");
+//        config.setPoolSize("1");
+//        encryptor.setConfig(config);
+//        return encryptor;
+//    }
 }

+ 57 - 0
backend/src/main/java/com/jiayue/ssi/config/EnvironmentPreparedListener.java

@@ -0,0 +1,57 @@
+package com.jiayue.ssi.config;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.jiayue.ssi.constant.SecretKeyConstants;
+import com.jiayue.ssi.util.SM2CryptUtils;
+import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
+import org.springframework.boot.env.OriginTrackedMapPropertySource;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+
+/**
+*
+*
+* @author xsl
+* @since 2023/08/11
+*/
+
+public class EnvironmentPreparedListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent>{
+    @Override
+    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
+        ConfigurableEnvironment env = event.getEnvironment();
+        MutablePropertySources pss = env.getPropertySources();
+        List<PropertySource> list = new ArrayList<>();
+        for(PropertySource ps : pss){
+            Map<String,Object>  map = new HashMap<>();
+            if(ps instanceof OriginTrackedMapPropertySource){
+                OriginTrackedMapPropertySource propertySource = new OriginTrackedMapPropertySource(ps.getName(),map);
+                Map<String,Object> src = (Map<String,Object>)ps.getSource();
+                src.forEach((k,v)->{
+                    String strValue = String.valueOf(v);
+                    if(strValue.startsWith("JY[") && strValue.endsWith("]")) {
+                        // 此处进行截取出对应的密文 BR23C92223KKDNUIQMPLS0009 ,然后调用对应的解密算法进行解密操作
+                        v=SM2CryptUtils.decrypt(strValue.substring(3, strValue.length()-1), SecretKeyConstants.SERVER_PRIVATE_KEY);
+                    }
+                    map.put(k,v);
+                });
+                list.add(propertySource);
+            }
+        }
+        /**
+         此处是删除原来的 OriginTrackedMapPropertySource 对象,
+         把解密后新生成的放入到 Environment,为什么不直接修改原来的
+         OriginTrackedMapPropertySource 对象,此处不做过多解释
+         不懂的可以去看看它对应的源码,也算是留一个悬念,也是希望大家
+         能够没事多看一看源码。
+         */
+        list.forEach(ps->{
+            pss.remove(ps.getName());
+            pss.addLast(ps);
+        });
+    }
+}

+ 1 - 0
backend/src/main/resources/META-INF/spring.factories

@@ -0,0 +1 @@
+org.springframework.context.ApplicationListener=com.jiayue.ssi.config.EnvironmentPreparedListener

+ 5 - 5
backend/src/main/resources/application.yml

@@ -3,7 +3,7 @@ server:
   ssl:
     key-store: classpath:9564748_api.jiayuepowertech.com.pfx
     key-store-type: PKCS12
-    key-store-password: ENC(6daOBtvpihAkIU2Kh8iRK3KqYgI4E0/s)
+    key-store-password: JY[7d28439aff975b7e01a6bde97cc460afbf70308b07b023809bf9d839e61284bb22ed37382bc5cd497b651b1f0e9e16befb8f590920cd9d2f452d30bcd8a06762199423c6f524f2085e66a3691fff57e7dd960714a8cc26da64f85a49ce18be812494fb33f29eea00]
     enabled-protocols: "TLSv1.2"
     ciphers: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
 
@@ -21,8 +21,8 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.alibaba.druid.pool.DruidDataSource
     url: jdbc:mysql://localhost:3307/ssi?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
-    username: ENC(UN5TVXHQJt2DbXQiX/GRsw==)
-    password: ENC(r9wV3VlMJEcxqJ6hYeG7BLRdUMXsPQHQ)
+    username: JY[15a0b9e58aef5b73fbbc12ce85ab5046b22a703e45019dbf7dd7041c8c60ea061cca717220548d86baa4cab57ebcc42db62172178c4cc299f243cfe7a3550e3b367284368dc3a183b350b92b810da5b2030a647aaede5baf735c6dcc77700a5325773e91]
+    password: JY[bbe20dde79320dfbe7bca925e07c57c13d079c72f1547fb97023020262a339f2a293e466cfc9ee9f0cb7c139bdcb78bccdf0fe9090a3da72a09f645873af6a7696c286540112c2d0f634a15ed013827d078b6edd6afc45df94278d5cd0da622a2c88f5e52b4ad5b7ab]
 
   #邮箱基本配置
   mail:
@@ -33,9 +33,9 @@ spring:
     # 163     smtp.163.com       端口号465或994
     host: smtp.263.net
     #发送者邮箱
-    username: ENC(4hsAvmDn50R1rxcYN5UdnSd69rFpv0dNp+6UOkHNTVz4go5lUgGvZw==)
+    username: JY[a531e2eb485e917e9a6d7a723d874c87e377f9dcfd2c8f67b4a6b2a21a981ffef69e5ac9ee14ff3ba9172a53093ebdd9a5527eccf297073c561fdc38ac9180489f463a5f246508f9aa646267967c7f08d2f4536fa5a7522277dcb6c7a98a12511689d1513fba04db29cc6d7bea222225334ce4ffbdb79718417713f36b]
     #配置密码,注意不是真正的密码,而是刚刚申请到的授权码
-    password: ENC(g8kj0/rxGdJ5qiETb0BsbWqYFf+/0gvk)
+    password: JY[e9cd08a9b1d7cde0abfc1dc613bf15133feaeeb8a0a96882e94a2e93d3a5ec95f1d14457ca308cb7c6a788fe88e76201cd843c1c40c0c4b70b60fb2450d1c0c213587748f8cdfe79002e3f00ed90d33905f3108708f32738b4b87fff5fe6ca4cf0457d669c5f60e5dd2f5b83]
     #端口号465或587
     port: 465
     #默认的邮件编码为UTF-8

+ 47 - 47
backend/src/test/java/com/jiayue/ssi/JasyptStringEncryptorDemo.java

@@ -1,56 +1,56 @@
 package com.jiayue.ssi;
 
-import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
-import org.jasypt.util.text.BasicTextEncryptor;
+//import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
+//import org.jasypt.util.text.BasicTextEncryptor;
 
 /**
  * @author xsl
  * @since 2023/04/25
  */
 public class JasyptStringEncryptorDemo {
-    public static void main(String[] args) {
-        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
-        textEncryptor.setPassword("atpingan");
-        System.out.println("==========ssl配置==========");
-        // key-store-password
-        String keyStorePassword = textEncryptor.encrypt("s37d1gxm");
-        System.out.println("keyStorePassword===>"+keyStorePassword);
-        // mysql:url
-        System.out.println("==========mysql配置==========");
-        String mysqlURL = textEncryptor.encrypt("jdbc:mysql://localhost:3306/ssi?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai");
-//        String mysqlURL = textEncryptor.encrypt("jdbc:mysql://192.168.1.208:3308/ssi?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai&useSSL=true&verifyServerCertificate=true&requireSSL=true&clientCertificateKeyStoreUrl=classpath:mysql_ssl/mysql-keystore&clientCertificateKeyStorePassword=jieyue6677*&trustCertificateKeyStoreUrl=classpath:mysql_ssl/mysql-truststore&trustCertificateKeyStorePassword=jieyue6677*");
-        System.out.println("mysqlURL===>"+mysqlURL);
-        String mysqlUserName = textEncryptor.encrypt("root");
-        System.out.println("mysqlUserName===>"+mysqlUserName);
-        String mysqlPassWord = textEncryptor.encrypt("!QAZ2root");
-        System.out.println("mysqlPassWord===>"+mysqlPassWord);
-        // mail
-        System.out.println("==========mail配置==========");
-        String mailUserName = textEncryptor.encrypt("xushilong@jiayuepowertech.com");
-        System.out.println("mailUserName===>"+mailUserName);
-        String mailPassWord = textEncryptor.encrypt("jiayue123456");
-        System.out.println("mailPassWord===>"+mailPassWord);
-    }
-
-    /**
-     * Jasypt 加密
-     *
-     * @param encryptor 加解密工具
-     * @param plaintext 需要加密的字符串
-     **/
-    public static void encryption(StandardPBEStringEncryptor encryptor, String plaintext) {
-        String ciphertext = encryptor.encrypt(plaintext);
-        System.out.println(plaintext + " : " + ciphertext);
-    }
-
-    /**
-     * Jasypt 解密
-     *
-     * @param encryptor  加解密工具
-     * @param ciphertext 需要解密的字符串
-     **/
-    public static void decrypt(StandardPBEStringEncryptor encryptor, String ciphertext) {
-        String plaintext = encryptor.decrypt(ciphertext);
-        System.out.println(ciphertext + " : " + plaintext);
-    }
+//    public static void main(String[] args) {
+//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
+//        textEncryptor.setPassword("atpingan");
+//        System.out.println("==========ssl配置==========");
+//        // key-store-password
+//        String keyStorePassword = textEncryptor.encrypt("s37d1gxm");
+//        System.out.println("keyStorePassword===>"+keyStorePassword);
+//        // mysql:url
+//        System.out.println("==========mysql配置==========");
+//        String mysqlURL = textEncryptor.encrypt("jdbc:mysql://localhost:3306/ssi?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai");
+////        String mysqlURL = textEncryptor.encrypt("jdbc:mysql://192.168.1.208:3308/ssi?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai&useSSL=true&verifyServerCertificate=true&requireSSL=true&clientCertificateKeyStoreUrl=classpath:mysql_ssl/mysql-keystore&clientCertificateKeyStorePassword=jieyue6677*&trustCertificateKeyStoreUrl=classpath:mysql_ssl/mysql-truststore&trustCertificateKeyStorePassword=jieyue6677*");
+//        System.out.println("mysqlURL===>"+mysqlURL);
+//        String mysqlUserName = textEncryptor.encrypt("root");
+//        System.out.println("mysqlUserName===>"+mysqlUserName);
+//        String mysqlPassWord = textEncryptor.encrypt("!QAZ2root");
+//        System.out.println("mysqlPassWord===>"+mysqlPassWord);
+//        // mail
+//        System.out.println("==========mail配置==========");
+//        String mailUserName = textEncryptor.encrypt("xushilong@jiayuepowertech.com");
+//        System.out.println("mailUserName===>"+mailUserName);
+//        String mailPassWord = textEncryptor.encrypt("jiayue123456");
+//        System.out.println("mailPassWord===>"+mailPassWord);
+//    }
+//
+//    /**
+//     * Jasypt 加密
+//     *
+//     * @param encryptor 加解密工具
+//     * @param plaintext 需要加密的字符串
+//     **/
+//    public static void encryption(StandardPBEStringEncryptor encryptor, String plaintext) {
+//        String ciphertext = encryptor.encrypt(plaintext);
+//        System.out.println(plaintext + " : " + ciphertext);
+//    }
+//
+//    /**
+//     * Jasypt 解密
+//     *
+//     * @param encryptor  加解密工具
+//     * @param ciphertext 需要解密的字符串
+//     **/
+//    public static void decrypt(StandardPBEStringEncryptor encryptor, String ciphertext) {
+//        String plaintext = encryptor.decrypt(ciphertext);
+//        System.out.println(ciphertext + " : " + plaintext);
+//    }
 }

+ 45 - 17
backend/src/test/java/com/jiayue/ssi/service/BcSm2Util.java

@@ -7,6 +7,7 @@ import cn.hutool.crypto.SecureUtil;
 import cn.hutool.crypto.SmUtil;
 import cn.hutool.crypto.asymmetric.KeyType;
 import cn.hutool.crypto.asymmetric.SM2;
+import com.jiayue.ssi.constant.SecretKeyConstants;
 import com.jiayue.ssi.util.SM2CryptUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.bouncycastle.asn1.gm.GMNamedCurves;
@@ -40,11 +41,18 @@ import java.util.Base64;
 public class BcSm2Util {
     public static void main(String[] args) {
         //需要加密的明文
-        String text = "测试";
-        String pv = "6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd";
-        String pu = "041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672";
+//        String text = "测试";
+//        String pv = "6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd";
+//        String pu = "041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672";
+//
+
+//        String a = SM2CryptUtils.decrypt("8fe02b3e2bd96292691c899e1e3008ec076708a56c509ff8572a96f7da45f7d649f441d988479e14d6f0230520b1c02f6b2df95f49f4833d791757fc5a6aee6d46ed445c60856d8e625aa92fa64d09a7c3f22705d82f0a3bfe5e91b99ee013587fc6c4240c7269989e", "6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd");
+//        System.out.println(a);
+
+
+
         //创建sm2 对象
-        SM2 sm2 = SmUtil.sm2(pv,pu);
+//        SM2 sm2 = SmUtil.sm2(pv,pu);
         //这里会自动生成对应的随机秘钥对 , 注意! 这里一定要强转,才能得到对应有效的秘钥信息
 //        byte[] privateKey = BCUtil.encodeECPrivateKey(sm2.getPrivateKey());
 //        //这里公钥不压缩  公钥的第一个字节用于表示是否压缩  可以不要
@@ -55,21 +63,41 @@ public class BcSm2Util {
 //        System.out.println("私钥: " + HexUtil.encodeHexStr(pv.getBytes()));
 //        System.out.println("公钥: " + HexUtil.encodeHexStr(pu.getBytes()));
         //得到明文对应的字节数组
-        byte[] dateBytes = text.getBytes();
-        System.out.println("数据: " + HexUtil.encodeHexStr(dateBytes));
-        //这里需要手动设置,sm2 对象的默认值与我们期望的不一致
-        sm2.setMode(SM2Engine.Mode.C1C3C2);
-        sm2.setEncoding(new PlainDSAEncoding());
-        //计算签名
-        byte[] sign = sm2.sign(dateBytes, null);
-        System.out.println("签名: " + HexUtil.encodeHexStr(sign));
-        // 校验  验签
-        boolean verify = sm2.verify(dateBytes, sign);
-        System.out.println(verify);
+//        byte[] dateBytes = text.getBytes();
+//        System.out.println("数据: " + HexUtil.encodeHexStr(dateBytes));
+//        //这里需要手动设置,sm2 对象的默认值与我们期望的不一致
+//        sm2.setMode(SM2Engine.Mode.C1C3C2);
+//        sm2.setEncoding(new PlainDSAEncoding());
+//        //计算签名
+//        byte[] sign = sm2.sign(dateBytes, null);
+//        System.out.println("签名: " + HexUtil.encodeHexStr(sign));
+//        // 校验  验签
+//        boolean verify = sm2.verify(dateBytes, sign);
+//        System.out.println(verify);
+//
+//
+//        String signold = SM2CryptUtils.sign(pv,text);
+//        System.out.println(signold);
+
+//        // SM3加密密码
+//        String sm3password = SmUtil.sm3("Xsl1234567890abcdefg").toUpperCase();
+        // 再对密码sm2
+
+        String keystore = SM2CryptUtils.encrypt("s37d1gxm",SecretKeyConstants.SERVER_PUBLIC_KEY);
+        System.out.println("keystore:"+keystore);
+
+        System.out.println("==========mysql配置==========");
+        String sm2dbusername = SM2CryptUtils.encrypt("root",SecretKeyConstants.SERVER_PUBLIC_KEY);
+        System.out.println("数据库用户名:"+sm2dbusername);
+        String sm2dbpwd = SM2CryptUtils.encrypt("!QAZ2root",SecretKeyConstants.SERVER_PUBLIC_KEY);
+        System.out.println("数据库密码:"+sm2dbpwd);
 
+        System.out.println("==========mail配置==========");
+        String mailUserName = SM2CryptUtils.encrypt("xushilong@jiayuepowertech.com",SecretKeyConstants.SERVER_PUBLIC_KEY);
+        System.out.println("mailUserName:"+mailUserName);
+        String mailPassWord = SM2CryptUtils.encrypt("jiayue123456",SecretKeyConstants.SERVER_PUBLIC_KEY);
+        System.out.println("mailPassWord:"+mailPassWord);
 
-        String signold = SM2CryptUtils.sign(pv,text);
-        System.out.println(signold);
 
     }
 }

+ 24 - 8
backend/src/test/java/com/jiayue/ssi/service/Sm2UiTest.java

@@ -11,13 +11,29 @@ import com.jiayue.ssi.util.SM2CryptUtils;
 */
 public class Sm2UiTest {
     public static void main(String[] args) {
-        // 返回前端的加密数据
-        String encrypt = "b249d7a7c5322dc66cce4cad025cd451182b841dff6ca4a35dc52c1a2145de3725ebf0aed4829d731c536d7de819a52e392748492ec86571696a621df0eabe5510fea6327f5b3da61573e9ff103c1765e234046371d8972a6547478d27219b94ecaef8ce2bfb28b9c9db5a3d64b706cf73fac1d6bde60f7d3ecd2ab2353a18d383ed85e4ad4e8a1ac27c607d12d411e69e294d8c89d7327c983566920ede54bc827b83e9f6e7514d0e9619cdddcc6b42f6a6dc608e74285a6e42";
-        // 返回前端签名数据
-        String signStr = "3046022100cabcfdfbe9969122c3748dec9e3bf0b277e1a7065a57c6654ea23694813f1c79022100da8611cc8928cdd9abb9094888c50a482918bb28aea509e0785c90b95899c9cf";
-        String text = SM2CryptUtils.decrypt(encrypt, SecretKeyConstants.CLIENT_PRIVATE_KEY);
-            System.out.println("解密:"+text);
-            boolean bo = SM2CryptUtils.verifySign(SecretKeyConstants.SERVER_PUBLIC_KEY,text,signStr);
-            System.out.println("验签:"+bo);
+//        // 返回前端的加密数据
+//        String encrypt = "b249d7a7c5322dc66cce4cad025cd451182b841dff6ca4a35dc52c1a2145de3725ebf0aed4829d731c536d7de819a52e392748492ec86571696a621df0eabe5510fea6327f5b3da61573e9ff103c1765e234046371d8972a6547478d27219b94ecaef8ce2bfb28b9c9db5a3d64b706cf73fac1d6bde60f7d3ecd2ab2353a18d383ed85e4ad4e8a1ac27c607d12d411e69e294d8c89d7327c983566920ede54bc827b83e9f6e7514d0e9619cdddcc6b42f6a6dc608e74285a6e42";
+//        // 返回前端签名数据
+//        String signStr = "3046022100cabcfdfbe9969122c3748dec9e3bf0b277e1a7065a57c6654ea23694813f1c79022100da8611cc8928cdd9abb9094888c50a482918bb28aea509e0785c90b95899c9cf";
+//        String text = SM2CryptUtils.decrypt(encrypt, SecretKeyConstants.CLIENT_PRIVATE_KEY);
+//            System.out.println("解密:"+text);
+//            boolean bo = SM2CryptUtils.verifySign(SecretKeyConstants.SERVER_PUBLIC_KEY,text,signStr);
+//            System.out.println("验签:"+bo);
+
+
+
+
+        String jiami = SM2CryptUtils.encrypt("root","041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672");
+        System.out.println("加密:"+jiami);
+        String jiemi = SM2CryptUtils.decrypt(jiami,"6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd");
+        System.out.println("解密:"+jiemi);
+
+
+        String qianming = SM2CryptUtils.sign("6155d63ee27cbeca07f3e40c4f8856f1be8119fcbda1aadc7e0e595e52bad7bd",jiemi);
+        System.out.println("签名:"+qianming);
+
+        boolean yanqian = SM2CryptUtils.verifySign("041967638ca43d4577d8dba166bff4437fde944270101f398a95b846ec2f8177d09f8abc5d62b6cd2c7216274d7abe0c8e04b0bb691207a32dd2e12d6bd2798672",jiemi,qianming);
+        System.out.println("验签:"+yanqian);
+
     }
 }

+ 6 - 5
backend/src/test/java/com/jiayue/ssi/service/Test.java

@@ -65,11 +65,12 @@ public class Test {
 //        Map<String,Object> map = JSONUtil.parseObj(str).getRaw();
 //        System.out.println(map.get("username"));
 //        System.out.println(map.get("password"));
-
-        System.out.println(SmUtil.sm3("B37926BDEC94A0AA7AB6C35998515B97126BBCF72CFC363B8CFE784828D631D0").toUpperCase());
-
-
-        System.out.println(Convert.toDBC("Xsl147258"));
+// 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0
+// 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0
+        System.out.println(SmUtil.sm3("abc"));
+//
+//
+//        System.out.println(Convert.toDBC("Xsl147258"));
 
 
     }