Cryptographically random data
suggest change// Create an array with a fixed size and type.
const array = new Uint8Array(5);
// Generate cryptographically random values
crypto.getRandomValues(array);
// Print the array to the console
console.log(array);
crypto.getRandomValues(array) fills an integer typed array. Float arrays throw TypeError. Each entry is chosen from the ranges below, both ends inclusive. The buffer must be at most 65,536 bytes.
Int8Array:-2**7through2**7 - 1Uint8Array:0through2**8 - 1Int16Array:-2**15through2**15 - 1Uint16Array:0through2**16 - 1Int32Array:-2**31through2**31 - 1Uint32Array:0through2**32 - 1BigInt64Array:-(2n**63n)through2n**63n - 1nBigUint64Array:0nthrough2n**64n - 1n
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents