Ad
Java's RSA/ECB/OAEPWithSHA-256AndMGF1Padding Equivalent In Node.js
The data decryption will run in JAVA using RSA/ECB/OAEPWithSHA-256AndMGF1Padding
algorithm. So I have to encrypt the data with public key using the algorithm equivalent to RSA/ECB/OAEPWithSHA-256AndMGF1Padding
in node.js
.
I tried with crypto.publicEncrypt(key, buffer)
which uses crypto.constants.RSA_PKCS1_OAEP_PADDING which is not similar to the above algorithm.
So I need algorithm equivalent to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" or how to achieve the same in node.js
Ad
Answer
I finally found the answer. Equivalent to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" can be achieved via node-forge npm module. https://www.npmjs.com/package/node-forge#rsa
// encrypt data with a public key using RSAES-OAEP/SHA-256/MGF1-SHA-1
// compatible with Java's RSA/ECB/OAEPWithSHA-256AndMGF1Padding
var encrypted = publicKey.encrypt(bytes, 'RSA-OAEP', {
md: forge.md.sha256.create(),
mgf1: {
md: forge.md.sha256.create()
}
});
Thank you
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad