From 151b08fe7ebd809092ec384cf4320900cb3fc9ce Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 22 Oct 2024 21:16:11 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20buffer=20convers?= =?UTF-8?q?ion=20errors=20in=20hash=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/crypto.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/crypto.ts b/packages/core/src/crypto.ts index 4c7f32fd09..9749ad330f 100644 --- a/packages/core/src/crypto.ts +++ b/packages/core/src/crypto.ts @@ -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 }