wechat-miniprogram / sm-crypto

miniprogram sm crypto library
MIT License
438 stars 88 forks source link

sm2加密无法处理全零的情况 #4

Open hadibu opened 5 years ago

hadibu commented 5 years ago

let keypair = sm2.generateKeyPairHex(); let publicKey = keypair.publicKey; // 公钥 let privateKey = keypair.privateKey; // 私钥 const cipherMode = 0; // 1 - C1C3C2,0 - C1C2C3,默认为1 let buf = Buffer.alloc(1); let encryptData = sm2.doEncrypt(buf.toString(), publicKey, cipherMode); // 加密结果 let dec = sm2.doDecrypt(encryptData, privateKey)

上述代码无法解密。