Dev Helpers
← Back

Hash a UTF-8 string

Hash a UTF-8 string 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(createHash("sha256").update("demo").digest("hex"));

Sample output

2a97516c354b68848cdbd8f54a226a0a55b21ed138e207ad6c5cbb9c00aa5aea