duanhongyi / gmssl

a python crypto for sm2/sm3/sm4
MIT License
488 stars 141 forks source link

请问有像js的sm2接口一样,只通过公钥加密的接口吗? #44

Open xhaoxiong opened 2 years ago

xhaoxiong commented 2 years ago
<script>
    function encrypt() {
        //公钥,16进制格式,由后端生成
        var pubkeyHex = "04813d4d97ad31bd9d18d785f337f683233099d5abed09cb397152d50ac28cc0ba43711960e811d90453db5f5a9518d660858a8d0c57e359a8bf83427760ebcbba";
        var encryptData = sm2Encrypt("SM2 Encryption Test", pubkeyHex, 0);
        console.log(encryptData);
    }
    </script>
Pedro-null commented 1 year ago

初始化CryptSM2时,给私钥赋值空字符串就可以了,可参考 关于登录接口突然失效了这档子事 这篇博文