Open hadibu opened 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)
上述代码无法解密。
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)
上述代码无法解密。