Install all dependencies using npm i
or yarn install
.
This repository has three scripts:
node generate
Generates a private and public key, exports them in PEM formatnode encrypt
Encrypts a message given a specific public keynode decrypt
Decrypts a encrypted message with your private key
To setup, first generate yourself a public key and a private key by running node generate
. Keep your private key to yourself and provide your public key to anyone you want to send secret messages to you.
To encrypt a secret message to someone, ask for their public key. In the encrypt.js
file, fill in their public key and a message you'd like to send them. Run this script using node encrypt
and send them over the logged encrypted message.
First, have someone encrypt a secret message using your public key. Take the encrypted message and fill it into your decrypt.js
file. Then, fill in your private key. Finally run node decrypt
to decrypt the resulting secret message!