cleaner solution for toHex

This commit is contained in:
overflowerror 2024-08-17 00:30:33 +02:00
parent 90317f1650
commit 187a1a1743

View file

@ -7,7 +7,7 @@ declare global {
} }
Uint8Array.prototype.toHex = function(): string { 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 { Uint8Array.prototype.hasPrefix = function(prefix: Uint8Array, bits: number): boolean {