k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Guides

createHMAC( algorithm, secret )

Creates a HMAC hashing object that can then be fed with data repeatedly, and from which you can extract a signed hash digest whenever you want.

Parameter
Type
Description

algorithm

string

The hashing algorithm to use. One of md4, md5, sha1, sha256, sha384, sha512, sha512_224, sha512_256 or ripemd160.

secret

string

A shared secret used to sign the data.

Returns:

Type
Description

object

A Hasher object.

import crypto from "k6/crypto";

export default function() {
  console.log(crypto.hmac("sha256", "a secret", "my data", "hex"));
  let hasher = crypto.createHash("sha256", "a secret");
  hasher.update("my ");
  hasher.update("data");
  console.log(hasher.digest("hex"));
}

createHMAC( algorithm, secret )


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.