JS Built-ins
cryptointermediate

crypto β€” values are in 0-255 range

πŸ“– Usage Example
const n = crypto.getRandomValues(new Uint8Array(1))[0]
n >= 0 && n <= 255  // β†’ true

Each random byte is in the range 0-255.

crypto.getRandomValues() β€” value range for Uint8Array

For a Uint8Array, values returned by crypto.getRandomValues() are in the range [0, 255].

Challenge: Verify that a random Uint8Array value is between 0 and 255 inclusive.

πŸ’‘ Hints (1)
  • β€’ Uint8Array holds 8-bit unsigned integers, so values are 0-255