diff --git a/crypto/utils.ts b/crypto/utils.ts index b30a8ef..35caffe 100644 --- a/crypto/utils.ts +++ b/crypto/utils.ts @@ -1,5 +1,6 @@ -export function bufToHex(buf: ArrayBufferLike): string { - return [...new Uint8Array(buf)].map((x) => x.toString(16).padStart(2, "0")) +export function bufToHex(buf: ArrayBufferLike | Uint8Array): string { + const u8Array = buf instanceof Uint8Array ? buf : new Uint8Array(buf); + return [...u8Array].map((x) => x.toString(16).padStart(2, "0")) .join(""); }