The decrypt() method decrypts some encrypted data.
Usage
Parameters
Name | Type | Description |
---|---|---|
algorithm | AesCtrParams, AesCbcParams, or AesGcmParams object | Defines the algorithm to use and any extra-parameters. The values given for the extra parameters must match those used in the corresponding [encrypt] call. |
key | CryptoKey | The key to use for decryption. |
data | ArrayBuffer, TypedArray, or DataView | The encrypted data to be decrypted (also known as ciphertext). |
Return Value
A Promise that resolves to a new ArrayBuffer containing the decrypted data.
Throws
Type | Description |
---|---|
InvalidAccessError | Raised when the requested operation is not valid with the provided key. For instance when an invalid encryption algorithm is used, or a key not matching the selected algorithm is provided. |
OperationError | Raised when the operation failed for an operation-specific reason. For instance, if the algorithm size is invalid, or errors occurred during the process of decrypting the ciphertext. |
Example
example-webcrypto-decrypt.js