我正在使用eciesjs npm 包进行加密和解密,此加密已成功完成,但在解密时出现错误:错误:预期私钥是长度为 32 的 Uint8Array。
这是我的代码如下:
import eciesjs from 'eciesjs'
const key=`0x12bcb941510e4a02037e03904554064a6bce209155572d69fd22c46cc4e68c3dae9175c4177d844f9a0114b85a1e0129a14ec33c3ebd64e144faa6c069581472`
const data= 'My text abc'
const cipher = eciesjs.encrypt(key, Buffer.from(data))
const encryptedData = cipher.toString('hex')
console.log('encryptedData ', encryptedData)
const decryptData = eciesjs.decrypt(key, encryptedData).toString()
console.log('decryptData = ', decryptData)
在解密时,我收到如下错误:
error: Error: Expected private key to be an Uint8Array with length 32