https://github.com/i404788/tiny-rsa
https://github.com/i404788/tiny-rsa
encrytion esnext rsa typescript
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/i404788/tiny-rsa
- Owner: i404788
- License: mit
- Created: 2019-07-01T10:22:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-20T11:40:57.000Z (almost 4 years ago)
- Last Synced: 2025-10-06T23:12:39.523Z (8 months ago)
- Topics: encrytion, esnext, rsa, typescript
- Language: JavaScript
- Size: 41 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny RSA
A tiny RSA implementation written in pure typescript, with tc39 bigint.
This module only relies on standard node.js libraries (Buffer & crypto currently)
## Requirements
* Deno OR Node.js >= 10.4 OR [a recent browser](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility)
## Features
* Supports padding
* OAEP (original)
* PKCS#1-OAEP
* Raw
* Includes reusable maths library for tc39 bigints
* Compressed releases on npm
* Supports Key Generations
* Any keysize (default 1024)
* Any public exponent (default: 0x10001)
* Tests
* Optimized math library
* ROCA tested
* Only 9.0kB on nodejs (3.7kB tarball)
## Basic Usage
```javascript
const rsa = require('tiny-rsa')
// This can take a few seconds
const key = rsa.generateKey(1024n)
// Uses OAEP padding with MGF1-sha256 (PKCS#1)
let ciphertext = rsa.Encrypt(Buffer.from("ABC"), key)
let plaintext = rsa.Decrypt(ciphertext, key)
console.log(plaintext.toString())
// Output: ABC
```
Docs coming soon(tm)
## Project structure
* src/ - Contains source code for tiny-rsa
* dist/ - Output after compiling tiny-rsa
* bench/ - Contains tests/benchmarks