getRandomBytes

Returns an ArrayBuffer containing length cryptographically secure random bytes

import { getRandomBytes } from "@roku-sdk/runtime/crypto";
getRandomBytes(length: number): ArrayBuffer

Description

Returns an ArrayBuffer containing length cryptographically secure random bytes.

Backed by the Roku runtime's global crypto.getRandomBytes() host function, which uses OpenSSL's RAND_bytes() (HW-backed CSPRNG via /dev/urandom).

Parameters

NameTypeDescription
lengthnumberNumber of bytes to generate. Must be a non-negative integer no greater than 65536.

Return values

An ArrayBuffer of length random bytes.


What’s Next

Did this page help you?