0

NodeJS have crypto module where DiffieHellman is a class. So, I can use this method to generate key and compute key.

But, client also need to create another instance of diffiehellman class. But how to do that? Can I use crypto module on client side? If yes then how, any solution? Here are my client side code...

const crypto = require('crypto');
const express = require('express');
const app = express();

// Generate server's keys...
const server = crypto.createDiffieHellman(139);
const serverKey = server.generateKeys();
//send p=prime and g=generator to the client
RAKTIM BANERJEE
  • 304
  • 4
  • 12

1 Answers1

1

Node.js has own "crypto" module to use DiffieHellman algorithm, so you can watch it and write it on browser on your own.

Second way is take library ready for use (on github or else), e.g. this one.

Pyroarsonist
  • 186
  • 1
  • 6
  • Sir, I want to use the library. i make a script to use this libreary already, but facing a error that **createDiffieHellman** is not a function.(your second option). I tried to read the readme.md but can't understand what i need to do. `` – RAKTIM BANERJEE Aug 19 '20 at 14:38
  • You cant do that on browser, because its a node.js module, not browser module. – Pyroarsonist Aug 20 '20 at 16:07
  • Maybe this should help: https://www.npmjs.com/package/crypto-browserify – Pyroarsonist Aug 20 '20 at 16:08
  • No, I tried this crypto-browserify but total failure. Here is my question https://stackoverflow.com/q/63500683/7483046 – RAKTIM BANERJEE Aug 20 '20 at 16:26
  • But, I tried to call createDiffiHellman, as they show in there example but. It arises error. After lot of observation I found they mistake `createDiffiHellman` spelling on `bundle.js`. After make it correct it says `this is not implemented yet`. And, I checked the bundle.js again and observe they only export the `createHash` properties which they shows in their example. And all other properties are not implemented yet. – RAKTIM BANERJEE Aug 20 '20 at 16:32