eciesjs 解密时出现错误`错误:预期私钥为长度为 32 的 Uint8Array`

问题描述

我正在使用 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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...