14 lines
467 B
TypeScript
14 lines
467 B
TypeScript
// Pre-Init
|
|
const LUT_HEX_4b = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
|
|
const LUT_HEX_8b = new Array(0x100);
|
|
for (let n = 0; n < 0x100; n++) {
|
|
LUT_HEX_8b[n] = `${LUT_HEX_4b[(n >>> 4) & 0xF]}${LUT_HEX_4b[n & 0xF]}`;
|
|
}
|
|
// End Pre-Init
|
|
export function toHex(buffer: Uint8Array): string {
|
|
let out = '';
|
|
for (let idx = 0, edx = buffer.length; idx < edx; idx++) {
|
|
out += LUT_HEX_8b[buffer[idx]];
|
|
}
|
|
return out;
|
|
} |