Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/latest/javascript-api/k6-crypto.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Menu
Open source
k6/crypto
Note
A module with a better and standard API exists.
The crypto module partially implements the WebCrypto API, supporting more features than k6/crypto.
The
k6/crypto module provides common hashing functionality available in the GoLang crypto package.
| Function | Description |
|---|---|
| createHash(algorithm) | Create a Hasher object, allowing the user to add data to hash multiple times, and extract hash digests along the way. |
| createHMAC(algorithm, secret) | Create an HMAC hashing object, allowing the user to add data to hash multiple times, and extract hash digests along the way. |
| hmac(algorithm, secret, data, outputEncoding) | Use HMAC to sign an input string. |
| md4(input, outputEncoding) | Use MD4 to hash an input string. |
| md5(input, outputEncoding) | Use MD5 to hash an input string. |
| randomBytes(int) | Return an array with a number of cryptographically random bytes. |
| ripemd160(input, outputEncoding) | Use RIPEMD-160 to hash an input string. |
| sha1(input, outputEncoding) | Use SHA-1 to hash an input string. |
| sha256(input, outputEncoding) | Use SHA-256 to hash an input string. |
| sha384(input, outputEncoding) | Use SHA-384 to hash an input string. |
| sha512(input, outputEncoding) | Use SHA-512 to hash an input string. |
| sha512_224(input, outputEncoding) | Use SHA-512/224 to hash an input string. |
| sha512_256(input, outputEncoding) | Use SHA-512/256 to hash an input string. |
| Class | Description |
|---|---|
| Hasher | Object returned by crypto.createHash(). It allows adding more data to be hashed and to extract digests along the way. |
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.
Choose a product
Viewing: v2.0.x (latest)
Find another version
Scroll for more