Dev Helpers
← Back

Compute an HMAC for a fixture

Compute an HMAC for a fixture using Node.js.

Open this example in the interactive library

Source code

import {
  createHash,
  createHmac,
  randomUUID,
  randomBytes,
  timingSafeEqual,
  generateKeyPairSync,
  sign,
  verify,
  createSecretKey,
} from "node:crypto";
console.log(
  createHmac("sha256", "demo-key").update("message").digest("base64"),
);

Sample output

SskAFTANO0Yz7wMHgfhYKuesgY03PFwR4Pzrzya8tMU=