Skip to content

Commit

Permalink
fix: πŸ› handle buffer conversion errors in hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 22, 2024
1 parent 3518e10 commit 151b08f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export async function hash(value: any, options?: HashOptions) {
await append(rest)

const buf = await h.digest()
let res = await buf.toString("hex")
let res: string
try {
res = await buf.toString("hex")
} catch (e) {
res = toHex(new Uint8Array(buf))
}
if (length) res = res.slice(0, length)
return res
}

0 comments on commit 151b08f

Please sign in to comment.