Skip to content

Instantly share code, notes, and snippets.

@mpneuried

mpneuried/dh_test.js

Created Oct 29, 2015
Embed
What would you like to do?
Diffie-Hellman Tests in Node
// Install: "npm i prompt"
// Usage: "node dh.js"
var crypto, dh, prompt;
crypto = require('crypto');
prompt = require('prompt');
dh = crypto.getDiffieHellman('modp5');
dh.generateKeys();
console.log("\nMy Pub:\n", dh.getPublicKey("hex"), "\n");
prompt.start();
prompt.get(['pub'], function(err, result) {
if (err) {
console.error(err);
return;
}
console.log("\nSECRET:\n", dh.computeSecret(result.pub, "hex", 'hex'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment