crypto-browserify icon indicating copy to clipboard operation
crypto-browserify copied to clipboard

Error when try to use Diffie-Hellman properties

Open Raktim123 opened this issue 5 years ago • 4 comments

I want to use this library in my project to archive NodeJS crypto on browser.

I already downloaded the above package. In the given example it shows createHash. I want to use .createDiffieHellman etc. But, it rises error. Here is my code.

<!doctype html>
<html>
<script src='bundle.js'></script>
<body>
<h1>Welcome</h1>
</body>
<script>
      console.log(require('crypto').createDiffieHellman(139));
</script>
</html>

and I facing error says, Uncaught TypeError: require(...).createDiffieHellman is not a function in the browser console.

Even I tried to change the code on my computer project/node_modules/crypto-browserify/example/index.html and also tried to copy the repository from github, but result is same.

I can't understand what happen?

Raktim123 avatar Aug 20 '20 08:08 Raktim123

how did you bundle it ?

calvinmetcalf avatar Aug 20 '20 14:08 calvinmetcalf

First off all I copied the bundle.js file on my project root folder and then just add <script src="bundle.js"></script> on my HTML file.

Raktim123 avatar Aug 21 '20 16:08 Raktim123

I observe two things that there are maybe one spelling mistake in bundle.js (line 406) It's actually createDiffieHellman not createDeffieHellman and another is that only only createHash was exported from bundle.js if I call other it says message like 'it is not implemented yet'.

Raktim123 avatar Aug 21 '20 16:08 Raktim123

#200 should hopefully fix this issue by trimming down the error messages to only those unimplemented as per the readme.

rawr51919 avatar Feb 02 '21 21:02 rawr51919