site-panzai/node_modules/ohash/dist/crypto/node/index.mjs

11 lines
453 B
JavaScript
Raw Normal View History

2026-11-13 13:57:04 +01:00
import { createHash } from "node:crypto";
const fastHash = /*@__PURE__*/ (() => globalThis.process?.getBuiltinModule?.("crypto")?.hash)();
const algorithm = "sha256";
const encoding = "base64url";
function digest(data) {
if (fastHash) return fastHash(algorithm, data, encoding);
const h = createHash(algorithm).update(data);
return globalThis.process?.versions?.webcontainer ? h.digest().toString(encoding) : h.digest(encoding);
}
export { digest };