在执行

decoded += decipher.final('utf8')

的时候提示错误

(node:26500) UnhandledPromiseRejectionWarning: Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt

请问是什么原因呢?


具体代码如下:

WXBizDataCrypt.prototype.decryptData = function (encryptedData, iv) {

// base64 decode

var sessionKey = Buffer.from(this.sessionKey, 'base64')

encryptedData = Buffer.from(encryptedData, 'base64')

iv = Buffer.from(iv, 'base64')


// try {

// 解密

var decipher = crypto.createDecipheriv('aes-128-cbc', sessionKey, iv)

// 设置自动 padding 为 true,删除填充补位

decipher.setAutoPadding(true)

var decoded = decipher.update(encryptedData, 'binary', 'utf8')

decoded += decipher.final('utf8')

decoded = JSON.parse(decoded)


// } catch (err) {

//   throw new Error('Illegal Buffer')

// }


if (decoded.watermark.appid !== this.appId) {

throw new Error('Illegal Buffer')

}


return decoded

}


展开全部
收起
2回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • Ayden

    19人对此回答表示赞同

    可以尝试一下

    展开
    19
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • 象牙_Sanya

    11人对此回答表示赞同

    https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxf25d506ff81e19fb&token=200365472&lang=zh_CN

    展开
    11
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部