Skip to content

Commit

Permalink
refactor: code clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nadilas committed May 31, 2024
1 parent 5174cb4 commit 1132c9f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/ogre/src/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export function digest(obj: any, algorithm = "SHA-256"): Promise<string> {
if (isBrowser()) {
const buf = await crypto.subtle.digest(algorithm, hashInput);
const h = "0123456789abcdef";
new Uint8Array(buf).forEach((v) => {
for (const v of new Uint8Array(buf)) {
digest += h[v >> 4] + h[v & 15];
});
}
} else {
const nodeAlg = algorithm.toLowerCase().replace("-", "");
digest = (await import("crypto"))
digest = (await import("node:crypto"))
.createHash(nodeAlg)
.update(Buffer.from(hashInput))
.digest("hex"); // eslint-disable-line
Expand Down

0 comments on commit 1132c9f

Please sign in to comment.