Convert from ArrayBuffer to hexadecimal and viceversa in Deno.
// example.ts
import { bufferToHex, hexToBuffer } from "https://deno.land/x/hextools/mod.ts";
const hex = bufferToHex(
new Uint8Array([
72,
101,
108,
108,
111,
32,
119,
111,
114,
108,
100,
]),
); // 48656c6c6f20776f726c64
const buffer = hexToBuffer(hex);
console.log(new TextDecoder().decode(buffer)); // Hello world
Converts from an ArrayBuffer to a hexadecimal string.
Converts from a hexadecimal string to ArrayBuffer.
Throws a TypeError
if hex length is not even or it has unrecognized
characters.