Polkadot Apps
    Preparing search index...

    Generate length cryptographically secure random bytes.

    Number of random bytes to generate.

    A Uint8Array of random bytes.

    • Cryptographically secure PRNG backed by crypto.getRandomValues.

      Parameters

      • OptionalbytesLength: number

        number of random bytes to generate

      Returns Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>

      Random bytes. The platform getRandomValues() implementation still defines any single-call length cap, and this helper rejects oversize requests with a stable library RangeError instead of host-specific errors.

      On wrong argument types. TypeError

      On wrong argument ranges or values. RangeError

      If the current runtime does not provide crypto.getRandomValues. Error

      Generate a fresh random key or nonce.

      const key = randomBytes(16);