# Decrypt Data with AES

The `decryptDataWithAES` performs symmetric encryption using the [Advanced Encryption Standard (AES)](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt#aes-gcm), specifically the Galois/ Counter Mode (GCM).

The `AES` key and the random initialized vector (`iv`) used at the time of encryption are needed to decrypt the data.

The `iv` is part of the `combinedArrayBuffer` returned as the encrypted data from the `encryptDataWithAES` function. The `decryptDataWithAES` functions splits this into the `iv` and actual `encryptedData` on the backend before decrypting the latter.

### Basic Syntax

The function is called as follows:

```javascript
import { decryptDataWithAES } from 'arweavekit/encryption';

const decryptedDataObject = await decryptDataWithAES({params});
```

### Input Parameters

The following params are available for this function and they must be passed in as an object:

* `data: ArrayBuffer` : The combination of the random initialized vector prepended to the encrypted data as an `ArrayBuffer` generated at the time of encryption.
* `key: string` : The encryption key generated at the time of data encryption using `AES-GCM` and used for encrypting the data.

<details>

<summary>Example</summary>

```javascript
const decryptedDataObject = await decryptDataWithAES({
    data: ArrayBuffer,
    key: string,
});
```

This encrypts the provided `ArrayBuffer` using the `AES-GCM` encryption method.

</details>

### Returned Data

The function call returns the following data:

```bash
decryptedData: ArrayBuffer
```

* `decryptedData: ArrayBuffer` : The decrypted data returned as an `ArrayBuffer`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arweavekit.com/encryption/decrypt-data-with-aes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
