Documentation Index
Fetch the curated documentation index at: https://grafana_com_website/llms.txt
Fetch the complete documentation index at: https://grafana_com_website/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: /docs/k6/latest/javascript-api/crypto/aescbcparams.md (append .md) or send Accept: text/markdown to /docs/k6/latest/javascript-api/crypto/aescbcparams/. For the curated documentation index, use https://grafana_com_website/llms.txt. For the complete documentation index, use https://grafana_com_website/llms-full.txt.
AesCbcParams
The AesCbcParams object represents the object that should be passed as the algorithm parameter into the
encrypt and
decrypt operation when using the AES-CBC algorithm.
For more details, head to the MDN Web Crypto API documentation on AES-CBC.
Properties
| 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
export default async function () {
const plaintext = stringToArrayBuffer('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
);
}
function stringToArrayBuffer(str) {
const buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
const bufView = new Uint16Array(buf);
for (let i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}Was this page helpful?
Related resources from Grafana Labs

