This package works fine with web browsers and servers
RSA is a public-key cryptoSystem that is widely used for secure data transmission. It is also one of the oldest. The acronym RSA comes from the surnames of Ron Rivest, Adi Shamir and Leonard Adleman, who publicly described the algorithm in 1977. Wikipedia
RSA algorithm is asymmetric cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key and Private Key. As the name describes that the Public Key is given to everyone and Private key is kept private.
npm i encrypt-rsa --only=production
// OR
yarn add encrypt-rsa --only=production
import EncryptRsa from 'encrypt-rsa';
//OR
const EncryptRsa = require('encrypt-rsa').default;
// create instance
const encryptRsa = new EncryptRsa();
const { privateKey, publicKey } = nodeRSA.createPrivateAndPublicKeys();
const encryptedText = encryptRsa.encrypt({
text: 'hello world',
privateKey,
});
console.log(encryptedText);
const decryptedText = nodeRSA.decrypt({
text: encryptedText,
publicKey
});
console.log(decryptedText);
// hello world
feel free to open an issue and make a pull request