https://github.com/wonism/rsa-light
RSA library that works on browser and node without any dependencies.
https://github.com/wonism/rsa-light
Last synced: about 2 months ago
JSON representation
RSA library that works on browser and node without any dependencies.
- Host: GitHub
- URL: https://github.com/wonism/rsa-light
- Owner: wonism
- Created: 2021-03-26T10:35:51.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-26T11:36:49.000Z (about 4 years ago)
- Last Synced: 2025-01-12T16:11:26.594Z (4 months ago)
- Language: TypeScript
- Size: 141 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# RSA Light


RSA library that works on browser and node without any dependencies.
## Installation
```sh
# npm
$ npm i -S rsa-light
# yarn
$ yarn add rsa-light
```
## Usage```ts
// 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);
``````ts
// 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));
```