node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »

simplersa

Simple module to ease use of the rsa public key encryption.

Usage:

var simplersa=require("simplersa");
var rsa=simplersa();

Generate keys

rsa.gen.pri(size=1024); // generate private and public keys
rsa.gen.pub(size=1024); // generate just public key for one time use

Set keys

rsa.set.pri(pkcs1-private-pem.key); // set private key
rsa.set.pub(pkcs8-public-pem.key); // set public key

Get keys

rsa.get.pri(); // return private key
rsa.get.pub(); // return public key

Encrypt / decrypt depending on the keys loaded

rsa.enc(text); // encrypt
rsa.dec(text); // decrypt

For web version use "web-simplersa.js"

Keys are exported as:

pkcs8-public-pem

and

pkcs1-private-pem