package com.jiayue.ssi.service;

import com.jiayue.ssi.constant.SecretKeyConstants;
import com.jiayue.ssi.util.SM2CryptUtils;

/**
* 解析返回前端的加密数据
*
* @author xsl
* @since 2023/03/14
*/
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);
    }
}
