Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standalone js file? #25

Open
dicoy-zz opened this issue Oct 17, 2017 · 5 comments
Open

standalone js file? #25

dicoy-zz opened this issue Oct 17, 2017 · 5 comments

Comments

@dicoy-zz
Copy link

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.

@calvinmetcalf
Copy link
Contributor

you're going to want to do browserify index.js -s dh which will make the library available under a variable 'dh'

@calvinmetcalf
Copy link
Contributor

and you'd actually want to do browserify browser.js -s dh

@dicoy-zz
Copy link
Author

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)

@calvinmetcalf
Copy link
Contributor

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.

@calvinmetcalf
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants