Crypto API
chevron down
 

Crypto API

getRandomValues()

Fill an array with cryptographically strong random values.

import { getRandomValues } from "crypto";
// get 8 random 16-bit unsigned integers
let myRandomValues = new Uint16Array(8);
getRandomValues(myRandomValues);

crypto.getRandomValues(values: TypedArray)

Parameters

values: TypedArray

Array of values that will be filled with random numbers.

TypedArray

String: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array

The types of supported arrays.