diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index dd31ae7ac3b92b..d6deed7d924759 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -325,19 +325,19 @@ const crypto = require('crypto'); const assert = require('assert'); // Generate Alice's keys... -const alice = crypto.createDiffieHellman(11); +const alice = crypto.createDiffieHellman(2048); const alice_key = alice.generateKeys(); // Generate Bob's keys... -const bob = crypto.createDiffieHellman(11); +const bob = crypto.createDiffieHellman(alice.getPrime(), alice.getGenerator()); const bob_key = bob.generateKeys(); // Exchange and generate the secret... const alice_secret = alice.computeSecret(bob_key); const bob_secret = bob.computeSecret(alice_key); -assert(alice_secret, bob_secret); - // OK +// OK +assert.equal(alice_secret.toString('hex'), bob_secret.toString('hex')); ``` ### diffieHellman.computeSecret(other_public_key[, input_encoding][, output_encoding])