Menu
Scroll for more
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Open source
b64encode( input, [encoding] )
| Parameter | Type | Description |
|---|---|---|
| input | string / ArrayBuffer | The input string or ArrayBuffer object to base64 encode. |
| encoding (optional) | string | The base64 encoding to use. Available options are: - “std”: the standard encoding with = padding chars and + and / characters in encoding alphabet. This is the default.- “rawstd”: like std but without = padding characters.- “url”: URL safe version of std, encoding alphabet doesn’t contain + and / characters, but rather - and _ characters.- “rawurl”: like url but without = padding characters. |
Returns
| Type | Description |
|---|---|
| string | The base64 encoding of the input data. |
Example
JavaScript
JavaScript
import { check } from 'k6';
import encoding from 'k6/encoding';
export default function () {
const str = 'hello world';
const enc = 'aGVsbG8gd29ybGQ=';
const buf = new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]).buffer;
check(null, {
'is encoding string correct': () => encoding.b64encode(str) === enc,
'is encoding ArrayBuffer correct': () => encoding.b64encode(buf) === enc,
});
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.