如何在学习国密加密方法时SM2方法?

在学习国密加密方法时SM2方法,使用前端解密,返回空白,麻烦帮忙看下
var SM2Key={
    // publicKey:SM2.generateKeyPairHex().publicKey , //公钥
    // privateKey:SM2.generateKeyPairHex().privateKey , //私钥
    publicKey:'042d0b79a4c6c699ef1db0af78ec4db6d95893dd3a52e8edde006cae152e73bd899aaa12def2b02570e30fc25d4bff6f2123860e404d26ff94c6258d33a30622e6' , //公钥
    privateKey:'da1bbdcc175c3d9e70de40d3ee1da6bd19210e17e9eb67b6fee34a6529015b82' , //私钥
    // compressedPublicKey :SM2.compressPublicKeyHex(publicKey) , //压缩公钥
    // SM2.comparePublicKeyHex(publicKey, compressedPublicKey)  判断压缩前后公钥是否等价
    // verifyResult :SM2.verifyPublicKey(this.publicKey),  //验证公钥
    cipherMode : 1,             // 1 - C1C3C2,0 - C1C2C3,默认为1
    encrypt:function (msg) {
        // console.log(this.publicKey);
        return SM2.doEncrypt(msg, this.publicKey, this.cipherMode)
    },
    decrypt:function(msg){
        // console.log( this.privateKey);
        return SM2.doDecrypt(msg, this.privateKey, this.cipherMode) 



// SM2Key
    let str4=SM2Key.encrypt('0000000000000')
    console.log(str4);
    console.log(SM2Key.decrypt(str4));
    console.log(`--------SM2Key加密---------`);
    }

}

望采纳!!!点击回答右侧采纳即可!!
返回空白的可能原因之一是使用的公钥或私钥不正确。
你可以检查它们是否匹配,以确保它们是正确的。还可能是加密和解密使用的模式不匹配。
你可以尝试更改 cipherMode 的值并重试。
还有可能是你加密的文本为空或者字符串长度过短。