{"size": 873, "ext": "js", "max_stars_repo_path": "app.js", "max_stars_repo_name": "trulymittal/ECDH-nodejs", "max_stars_repo_stars_event_min_datetime": "2020-09-03T17:13:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T01:32:44.000Z", "max_issues_repo_path": "app.js", "max_issues_repo_name": "trulymittal/ECDH-nodejs", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app.js", "max_forks_repo_name": "trulymittal/ECDH-nodejs", "max_forks_repo_forks_event_min_datetime": "2021-06-04T11:30:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-13T20:02:38.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 30.1034482759, "max_line_length": 80, "alphanum_fraction": 0.7399770905}
const crypto = require('crypto');

const alice = crypto.createECDH('secp256k1');
alice.generateKeys();

const bob = crypto.createECDH('secp256k1');
bob.generateKeys();

const alicePublicKeyBase64 = alice.getPublicKey().toString('base64');
const bobPublicKeyBase64 = bob.getPublicKey().toString('base64');

const aliceSharedKey = alice.computeSecret(bobPublicKeyBase64, 'base64', 'hex');
const bobSharedKey = bob.computeSecret(alicePublicKeyBase64, 'base64', 'hex');

console.log(aliceSharedKey === bobSharedKey);
//Shared key in hex
console.log('Alice shared Key: ', aliceSharedKey);
//Shared key in hex
console.log('Bob shared Key: ', bobSharedKey);
//Shared key length in bits (=256 bits)
console.log(
  'Shared Key length of alice(same as bob): ',
  aliceSharedKey.length * 4
);
console.log(
  'Shared Key length of bob(same as alice): ',
  aliceSharedKey.length * 4
);
