🔢 Generates an array of cryptographically secure random bytes.
Uses the standard Web Crypto API (globalThis.crypto).
Syntax
TypeScript
import { randomBytes } from '@opentf/std'; randomBytes(size: number): Uint8Array;
Parameters
size: The number of bytes to generate.
size must be a non-negative integer.
Returns
A Uint8Array containing the random bytes.
Examples
TypeScript
randomBytes(16) //=> Uint8Array(16) [ ... ]