Files
Vincent Koc 60af9ef6b3 refactor(verifiers): share whole-file SHA-256 hashing (#14475)
* refactor(verifiers): share whole-file SHA-256 hashing

* fix(verifiers): type the streamed digest input
2026-11-25 10:01:22 +00:00

13 lines
396 B
JavaScript

import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
/**
* Stream a verifier input into a lowercase hexadecimal SHA-256 digest.
* @param {import("node:fs").PathLike} path
*/
export const sha256File = async (path) => {
const hash = createHash("sha256");
for await (const bytes of createReadStream(path)) hash.update(bytes);
return hash.digest("hex");
};