Class Crypto

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

Hierarchy

  • Crypto

Implements

Accessors

Methods

Accessors

Methods

  • Fills the provided TypedArray with cryptographically strong random values.

    Type Parameters

    Parameters

    • array: T

      The TypedArray to fill with random values.

    Returns T

    The same TypedArray filled with random values.

    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

  • Generates a cryptographically strong random unique identifier (UUID).

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

    A string representation of a UUID.

    Example

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

    See

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

Generated using TypeDoc