Skip to main content
Version: v3+

getRandomValues

Start from API_LEVEL 5.0 . Please refer to API_LEVEL.

Fills the supplied Uint8Array with hardware-generated random values and returns the same array object. Throws an exception on failure.

Type​

function getRandomValues(array: InputArray): Result

Parameters​

InputArray​

TypeDescription
Uint8ArrayThe Uint8Array to fill with hardware-generated random values

Result​

TypeDescription
Uint8ArrayThe original array filled with random values

Example​

import { getRandomValues } from '@zos/crypto'

const bytes = new Uint8Array(16)
getRandomValues(bytes)
console.log(bytes)