rsa-light
v1.0.0
Published
RSA library that works on browser and node without any dependencies.
Downloads
103
Maintainers
Readme
RSA Light
RSA library that works on browser and node without any dependencies.
Installation
# npm
$ npm i -S rsa-light
# yarn
$ yarn add rsa-light
Usage
// without signature
import RSA from 'rsa-light';
const rsaKey = RSA.generateRSAKey(512);
const publicKeyString = RSA.publicKeyString(rsaKey);
const encryptionResult = RSA.encrypt('Some Plain Text', publicKeyString);
const decryptionResult = RSA.decrypt(encryptionResult, rsaKey);
console.log(decryptionResult.plainText);
console.log(decryptionResult.signature);
// with signature
import RSA from 'rsa-light';
const rsaKey = RSA.generateRSAKey(512);
const publicKeyString = RSA.publicKeyString(rsaKey);
const signature = RSA.generateRSAKey(512);
const encryptionResult = RSA.encrypt('Some Plain Text', publicKeyString, signature);
const publicKeyId = RSA.publicKeyId(RSA.publicKeyString(signature));
const decryptionResult = RSA.decrypt(encryptionResult, rsaKey);
console.log(publicKeyId);
console.log(decryptionResult.plainText);
console.log(decryptionResult.signature);
console.log(decryptionResult.publicKey);
console.log(RSA.publicKeyString(signature));
console.log(RSA.publicKeyId(decryptionResult.publicKey));