@f0c1s/generate-keys
v2022.0.0
Published
Predefined keys generated for given passphrase; returns {privateKey, publicKey}
Downloads
5
Readme
node-generate-keys
Predefined keys generated for given passphrase; returns {privateKey, publicKey}
Encrypt and decrypt example #1
import {generateAPair} from "./generate";
import {privateDecrypt, publicEncrypt} from "crypto";
const passphrase = 'nani?';
const message = `it's over 9000!!!`;
const {publicKey, privateKey, generatePrivateKey} = generateAPair(passphrase);
const encrypted = publicEncrypt(publicKey, Buffer.from(message));
const decrypted = privateDecrypt(generatePrivateKey(Buffer.from(privateKey.toString()), passphrase), encrypted);
Encrypt and decrypt example #2
import {generateAPair} from "./generate";
import {privateDecrypt, publicEncrypt} from "crypto";
const passphrase = 'nani?';
const message = `it's over 9000!!!`;
const {publicKey, privateKey, generatePrivateKey, generatePublicKey} = generateAPair(passphrase);
const generatedPublicKey = generatePublicKey(publicKey.toString());
const encrypted = publicEncrypt(generatedPublicKey, Buffer.from(message));
const decrypted = privateDecrypt(generatePrivateKey(Buffer.from(privateKey.toString()), passphrase), encrypted);