From 187a1a1743d49e28f7ace9a620334b0164711f8c Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sat, 17 Aug 2024 00:30:33 +0200 Subject: [PATCH] cleaner solution for toHex --- src/hash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hash.ts b/src/hash.ts index b7060b7..6c81cb4 100644 --- a/src/hash.ts +++ b/src/hash.ts @@ -7,7 +7,7 @@ declare global { } Uint8Array.prototype.toHex = function(): string { - return [...this].map(c => (c >> 4).toString(16) + (c & 15).toString(16)).join(""); + return [...this].map(c => c.toString(16).padStart(2, "0")).join(""); }; Uint8Array.prototype.hasPrefix = function(prefix: Uint8Array, bits: number): boolean {