rsa-hybrid-crypto
v1.0.2
Published
Simple RSA public/private key encryption and descryption utilities
Maintainers
Readme
#rsa-hybrid-crypto
Hybrid encryption module using RSA + AES-GCM Supports large payloads (objects,strings,buffers,arrays).
You can generate RSA keys using the following commands:
Create an empty file (optional)
touch
Generate a 4096-bit RSA key pair in PEM format
ssh-keygen -t rsa -b 4096 -m PEM -f
Convert the public key (.pub) into a .pem file
ssh-keygen -f .pub -e -m PEM > .pem
Notes:
is the base name for your key files.
This will create:
→ private key
.pub → public key
.pem → PEM-formatted public key suitable for your module
##usage
import { encrypt, decrypt } from "rsa-hybrid-crypto";
const payload = { name: "alice", age: "28" };
const encrypted = encrypt("your public key", payload);
const decrypted = decrypt(
encrypted,
"your PRIVATE_KEY",
"passPhrase(optional)",
"if you want parseJSON pass true"
);