We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

window.crypto.getRandomValues Redirect 1

« DOM Reference

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

This method lets you get cryptographically random values.




Parameter Description
typedArray Integer-based TypedArray. All elements in the array are going to be overridden with random numbers.


If you provide an integer-based TypedArray (i.e. Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array), the function is going fill the array with cryptographically random numbers. The browser is supposed to be using a strong (pseudo) random number generator. Because the browser probably only has a limited amount of entropy, the method is free to throw the QuotaExceededError, if too much entropy is drained.


/* assuming that window.crypto.getRandomValues is available */

var array = new Uint32Array(10);

console.log("Your lucky numbers:");
for (var i = 0; i < array.length; i++) {

Browser Compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 11.0 WebKit bug 22049 21.0 11.0 15.0 3.1
Feature Android Browser Chrome (as App) Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari
Basic support Not supported 23 21.0 Not supported Not supported iOS 6


See also

Document Tags and Contributors

Last updated by: Sheppy,