encodeHex
import { encodeHex } from "jsr:@ende/encoding/unstable-hex";function ยท experimental
function encodeHex(input: string | Uint8Array_ | ArrayBuffer): stringencodeHex takes an input source and encodes it into a hexadecimal string.
If a Uint8Array<ArrayBuffer> or ArrayBuffer is
provided, the underlying source will be detached and reused for the encoding.
If you need the input source after providing it to this function, call
.slice() to pass in a copy.
input: string | Uint8Array_ | ArrayBufferThe input source to encode.
Returns
The hexadecimal string representation of the input.
Example: Basic Usage
import { assertEquals } from "@ende/assert";
import { encodeHex, type Uint8Array_ } from "@ende/encoding/unstable-hex";
assertEquals(encodeHex("Hello World"), "48656c6c6f20576f726c64");
assertEquals(
encodeHex(new TextEncoder().encode("Hello World") as Uint8Array_),
"48656c6c6f20576f726c64",
);