Skip to main content

Function.decrypt

function decrypt(key: JsonWebKey, data: EncryptedData): Promise<string>

Decrypts the given encrypted data using the provided key.

Size Details:

  • IV (Initialization Vector): Must be 96 bits (12 bytes) for AES-GCM.
  • Key: Must match the length specified during generation (here 256 bits).
  • Ciphertext: Variable size depending on the encrypted data.

Parameters

ParameterTypeDescription
keyJsonWebKeyThe JsonWebKey used for decryption.
dataEncryptedDataThe encrypted data containing the initialization vector (iv) and the ciphertext.

Returns

Promise<string>

A promise that resolves to the decrypted text.

Throws

If decryption fails.