nx.js
Classes

Crypto

Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives.

See

https://developer.mozilla.org/docs/Web/API/Crypto

Implements

Accessors

subtle

get subtle(): SubtleCrypto

A SubtleCrypto which can be used to perform low-level cryptographic operations.

See

https://developer.mozilla.org/docs/Web/API/Crypto/subtle

Returns

SubtleCrypto

Implementation of

globalThis.Crypto.subtle

Methods

getRandomValues()

getRandomValues<T>(array): T

Fills the provided TypedArray with cryptographically strong random values.

Type Parameters

Type Parameter
T extends null | ArrayBufferView

Parameters

ParameterTypeDescription
arrayTThe TypedArray to fill with random values.

Returns

T

The same TypedArray filled with random values.

Implementation of

globalThis.Crypto.getRandomValues

Example

const array = new Uint32Array(10);
crypto.getRandomValues(array);
 
console.log("Your lucky numbers:");
for (const num of array) {
  console.log(num);
}

See

https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues


randomUUID()

randomUUID(): `${string}-${string}-${string}-${string}-${string}`

Generates a cryptographically strong random unique identifier (UUID).

Returns

`${string}-${string}-${string}-${string}-${string}`

A string representation of a UUID.

Implementation of

globalThis.Crypto.randomUUID

Example

const uuid = crypto.randomUUID();
console.log(uuid);
// "36b8f84d-df4e-4d49-b662-bcde71a8764f"

See

https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID

On this page