---
title: "AesCbcParams | Grafana k6 documentation"
description: "AesCbcParams represents the object that should be passed as the algorithm parameter into the encrypt and decrypt operation when using the AES-CBC algorithm."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# AesCbcParams

The `AesCbcParams` object represents the object that should be passed as the algorithm parameter into the [encrypt](/docs/k6/v2.3.x/javascript-api/crypto/subtlecrypto/encrypt/) and [decrypt](/docs/k6/v2.3.x/javascript-api/crypto/subtlecrypto/decrypt/) operation when using the AES-CBC algorithm.

For more details, head to the [MDN Web Crypto API documentation on AES-CBC](https://developer.mozilla.org/en-US/docs/Web/API/AesCbcParams).

## Properties

Expand table

| Property | Type                                       | Description                                                                                                                                                                  |
|----------|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name     | `string`                                   | Should be set to `AES-CBC`.                                                                                                                                                  |
| iv       | `ArrayBuffer`, `TypedArray`, or `DataView` | The initialization vector. Must be 16 bytes, unpredictable and cryptographically random. Yet, it doesn’t need to be secret and can be transmitted along with the ciphertext. |

## Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
export default async function () {
  const plaintext = new TextEncoder().encode('Hello, World!');

  /**
   * Generate a symmetric key using the AES-CBC algorithm.
   */
  const key = await crypto.subtle.generateKey(
    {
      name: 'AES-CBC',
      length: 256,
    },
    true,
    ['encrypt', 'decrypt']
  );

  /**
   * Encrypt the plaintext using the AES-CBC key with
   * have generated.
   */
  const ciphertext = await crypto.subtle.encrypt(
    {
      name: 'AES-CBC',
      iv: crypto.getRandomValues(new Uint8Array(16)),
    },
    key,
    plaintext
  );
}
```
