keygentoolshed
Version:
Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3
15 lines (11 loc) • 654 B
JavaScript
import crypto from 'crypto';
const alice = crypto.createDiffieHellman(2048);
const bob = crypto.createDiffieHellman(alice.getPrime(), alice.getGenerator());
const aliceKey = alice.generateKeys();
const bobKey = bob.generateKeys();
const aliceSecret = alice.computeSecret(bobKey.getPublicKey());
const bobSecret = bob.computeSecret(aliceKey.getPublicKey());
console.log('Alice\'s Public Key:', alice.getPublicKey().toString('hex'));
console.log('Bob\'s Public Key:', bob.getPublicKey().toString('hex'));
console.log('Alice\'s Shared Secret:', aliceSecret.toString('hex'));
console.log('Bob\'s Shared Secret:', bobSecret.toString('hex'));