Dev Helpers
← Back

Copy an in-progress hash

Copy an in-progress hash 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(
  (() => {
    const h = createHash("sha256").update("base");
    return (
      h.copy().update("a").digest("hex") !== h.copy().update("b").digest("hex")
    );
  })(),
);

Sample output

true