Open dicoy-zz opened 7 years ago
you're going to want to do browserify index.js -s dh
which will make the library available under a variable 'dh'
and you'd actually want to do browserify browser.js -s dh
okk, so I did that, and got this as a result: https://codepen.io/dicoy/pen/zEyvXE
I only have the crypto.getRandomValues() function and it won't take any value I give it.
Sorry to bother you so much, but could you show me an example. Something I could paste into the console to see it work, like: var buffer = new ArrayBuffer(12); var x = new DataView(buffer); crypto.getRandomValues(x);
I promise you I'll do something cool with it and credit you properly (I'm planning on mixing it with http://myjson.com/ and doing "serverless" stuff)
codepen doesn't execute the js in the same context as the console of the page so that's why it doesn't work.
more generally this is meant to work with browserify or webpack so if you build an app with those you can just do require('crypto')
and almost all the crypto api is available. so if you're planing on building something bigger that uses this, that would probably be the easier way to do so.
also if your doing stuff in the browsery you almost certainly want to be doing elliptical curve diffie-hellman not the regular kind as this doesn't really scale as well to stronger key size.
if your using ecdh you can also use my other module native-crypto which will use built in browser stuff, once I merge calvinmetcalf/native-crypto#19
I tried running "browserify index.js" to get the actual lib but I doesn't seem to work. It would be awesome if you could show and example of it working to get an idea on how to use it.