Skip to main content

Function.generateKey

function generateKey(): Promise<JsonWebKey>

Generates a cryptographic key and exports it in JSON Web Key (JWK) format.

This function uses the AES-GCM (Advanced Encryption Standard - Galois/Counter Mode) algorithm, which provides authenticated encryption. AES-GCM ensures both the confidentiality and integrity of the data by combining AES encryption with Galois/Counter Mode for authentication.

Size Details:

  • Key: 256 bits (32 bytes) in this case, offering a high level of security.

Returns

Promise<JsonWebKey>

A promise that resolves to the generated key in JWK format.

Throws

Throws a CryptoError if key generation or export fails.