HTML DOM crypto.getRandomValues() method
The crypto getRandomValues() method lets you get cryptographic random values. The array given as the parameter to this method gets filled with cryptographic random numbers.
var a = window.crypto.getRandomValues(Array);
- Array: An integer-based Array, can be Int8Array, UInt8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array. All elements in the array are overwritten with random numbers after using this method.
Return Value: The Array passed in this method is overwritten and returned.
Example: This example uses the getRandomValues() method to generate a random Uint32Array of size 10.
Before Clicking Button:
After Clicking Button:
- Google Chrome
- Internet Explorer