版权声明:转载请评论留言 https://blog.csdn.net/solocao/article/details/89762615
在使用微信官方WXBizDataCrypt.js
解密encryptedData
获取敏感数据的时候,偶尔会报错。
DeprecationWarning: Buffer() is deprecated due to security and usability issues.
Please use the Buffer.alloc(),Buffer.allocUnsafe(), or Buffer.from() methods instead.
message: Illegal Buffer, stack: Error: Illegal Buffer at WXBizDataCrypt.decryptData
这种错误一定概率出现,一般出现在项目初始化的时候。
我一开始还以为是Buffer
库的问题,使用了safer-buffer
替换,还是没有解决。
网上还有人说需要encodeURIComponent
对参数包裹,这也不能解决。
其实,最后的解决办法,就是在小程序端
通过open-type="getUserInfo"
获取参数之前,必须要wx.login
。
所以,重要的事情说三遍: