js-hub / utils /hexFromBytes.ts
coyotte508's picture
coyotte508 HF Staff
Add 1 files
21dd449 verified
export function hexFromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("hex");
} else {
const bin: string[] = [];
arr.forEach((byte) => {
bin.push(byte.toString(16).padStart(2, "0"));
});
return bin.join("");
}
}