JS Built-ins
cryptobeginner

crypto β€” returned array has correct length

πŸ“– Usage Example
const rand = new Uint32Array(1)
crypto.getRandomValues(rand)
rand[0]  // β†’ a random 32-bit integer

Use Uint32Array to get a random unsigned 32-bit integer.

crypto.getRandomValues() β€” length preservation

When crypto.getRandomValues(typedArray) is called, the returned array maintains the same length as the input array.

Challenge: Verify that an 8-element array returned from getRandomValues has length 8.

πŸ’‘ Hints (1)
  • β€’ getRandomValues fills the array in place without changing its length