rain
2024-08-05 94174d2cc22afed6f41c270d970903484bfc5708
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.dji.sample.droneairport.utils.SM2;
 
import java.util.Map;
 
public class Test {
 
    public static void main(String[] args) throws Exception {
        Map<String, String> createKeyPair = Utils.createKeyPair();
        System.out.println("秘钥对:" + createKeyPair);
        String privateKey = createKeyPair.get(KeyConstant.PRIVATE_KEY);
        String publicKey = createKeyPair.get(KeyConstant.PUBLIC_KEY);
        String text = "test";
        String encrypt = Utils.encrypt(text, "049709f467dfdc4382657e081d18d4cf781f06996b2df6876f061615ff4a3ead7daba0fbc2b98c1a4ddee53db93f62b0f530b403e34141eb775277f434406a679a",ModeTypeEnum.BASE_MODE.getType());
        System.out.println("加密后密文:" + encrypt);
        String decrypt = Utils.decrypt(encrypt, "8b5afb843ca2a2d5bb12fc3442e7a17857a1d41c67c8212bb98a4943e28dfe8b",ModeTypeEnum.BASE_MODE.getType());
        System.out.println("解密后明文:" + decrypt);
    }
 
}