我有一个http请求,其中我想传递一些敏感数据,所以我试图加密这些数据。在我的React中,我生成了一对带有react本机-rsa本机的密钥,我通过函数RSA.encrypt(我的字符串,我的公钥)用公钥加密我的字符串。
之后,我在我的http请求中发送生成的密码数据,并尝试在我的node.js环境(Google函数)中解密它。为此,我使用Crypto模块。
我进口它时:
const crypto = require('crypto');我试图用在我的react本机模块中生成的RSA私钥解密我的数据:
crypto.privateDecrypt(rsaPrivateKey, myCryptedString)但我得到了一个错误:
exports.createPaymentMethod.functions.https.onRequest (/user_code/index.js:928:10)位于/var/tmp/worker/worker.js:783:7 at /var/tmp/worker/worker:(/user_code/node_modules/firebase-functions/lib/providers/https.js:37:41) (/user_tmp/index.js:928:10)。js:766:11在_combinedTickCallback (内部/process/next_tick.js:73:7)在process._tickDomainCallback (内部/process/next_tick.js:128:9)
有人能解决我的问题吗?
发布于 2019-04-19 21:07:34
根据文档,密文应该是Buffer的实例,而不是String,因此您可以尝试将密文包装到缓冲区中:
crypto.privateDecrypt(rsaPrivateKey, Buffer.from(myCryptedString))
https://stackoverflow.com/questions/55767799
复制相似问题