We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a form that I'm encrypting with react-native-rsa-native:
react-native-rsa-native
const form = { value: 1, value2: 2 }; const encryptedBody = await RSA.encrypt(JSON.stringify(body), FORM_PUBLIC_KEY); const body = { encryptedBody }; await fetch('/to/path', { body: JSON.stringify(body) });
I receive it on the backend as expected, now I try to decrypt it with node-rsa:
const fs = require('fs').promises; const path = require('path'); const NodeRSA = require('node-rsa'); async function decryptFormBody (body) { const privateKey = await fs.readFile( path.join(__dirname, '../resources/forms.key'), 'utf8' ); console.log(privateKey); const nodeRsa = new NodeRSA(privateKey); const { encryptedBody } = JSON.parse(body); return nodeRsa.decrypt(encryptedBody); }
I keep on getting this error:
{ "errorType": "Error", "errorMessage": "Error during decryption (probably incorrect key). Original error: Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error", "stack": [ "Error: Error during decryption (probably incorrect key). Original error: Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error", " at NodeRSA.module.exports.NodeRSA.$$decryptKey (/opt/nodejs/node_modules/node-rsa/src/NodeRSA.js:301:19)", " at NodeRSA.module.exports.NodeRSA.decrypt (/opt/nodejs/node_modules/node-rsa/src/NodeRSA.js:249:21)", " at decryptFormBody (/opt/nodejs/utils/decryptFormBody.js:16:18)", " at async Runtime.handler (/var/task/src/functions/subscribe.js:15:25)" ] }
I know that the private and public keys are correct. Here's how I generate my keys https://gist.github.com/aprilmintacpineda/baa777820819c14cae26d795517eb87e
The text was updated successfully, but these errors were encountered:
Hi, I had the same error. i fixed it like this: #215 (comment)
publicKey.encrypt(""); const decryptedData = privateKey.decrypt("your base64 encryption", "utf8");
Sorry, something went wrong.
i fix it。because node-rsa use pkcs1_oaep. so need to add code:
key.setOptions({ encryptionScheme: 'pkcs1' });
No branches or pull requests
I have a form that I'm encrypting with
react-native-rsa-native
:I receive it on the backend as expected, now I try to decrypt it with node-rsa:
I keep on getting this error:
I know that the private and public keys are correct. Here's how I generate my keys https://gist.github.com/aprilmintacpineda/baa777820819c14cae26d795517eb87e
The text was updated successfully, but these errors were encountered: