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
Parameter | Type | Description |
---|---|---|
key | JsonWebKey | The JsonWebKey used for decryption. |
data | EncryptedData | The 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.