@ende/encoding/unstable-hex
ende add jsr:@ende/encodingVersion 2026.10.15 on JSR.
Functions to encode and decode to and from hexadecimal strings.
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",
);
Exports
calcSizeHex— Calculate the output size needed to encode a given input size for encodeIntoHex.decodeHex— `decodeHex` takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format.encodeHex— `encodeHex` 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.encodeIntoHex— `encodeIntoHex` takes an input source and encodes it as hex into the output buffer.Uint8Array_— Proxy type of {@code Uint8Array<ArrayBuffer>} or {@code Uint8Array} in TypeScript 5.7 or below respectively.