How do I generate cryptographically secure random numbers in javascript?
There's been discussion at WHATWG on adding this to the window.crypto object. You can read the discussion and check out the proposed API and webkit bug (22049).
Just tested the following code in Chrome to get a random byte:
(function(){ var buf = new Uint8Array(1); window.crypto.getRandomValues(buf); alert(buf[0]); })();
2.1m questions
2.1m answers
60 comments
57.0k users