Skip to content

Instantly share code, notes, and snippets.

@mpneuried
Created October 29, 2015 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpneuried/cd3c7611482486575d71 to your computer and use it in GitHub Desktop.
Save mpneuried/cd3c7611482486575d71 to your computer and use it in GitHub Desktop.
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