rsa-light
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

RSA Light

GitHub Workflow Status (branch) npm npm bundle size

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));

Package Sidebar

Install

npm i rsa-light

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

523 kB

Total Files

26

Last publish

Collaborators

  • wonism