@ende/encoding/unstable-base32
ende add jsr:@ende/encodingVersion 2026.10.15 on JSR.
Functions to encode and decode to and from base32 strings.
import { assertEquals } from "@ende/assert";
import {
encodeBase32,
type Uint8Array_
} from "@ende/encoding/unstable-base32";
assertEquals(
encodeBase32("Hello World", { alphabet: "base32" }),
"JBSWY3DPEBLW64TMMQ======",
);
assertEquals(
encodeBase32(
new TextEncoder().encode("Hello World") as Uint8Array_,
{ alphabet: "base32" },
),
"JBSWY3DPEBLW64TMMQ======",
);
Exports
Base32Alphabet— The base32 alphabets.Base32Options— Options for encoding and decoding base32 strings.calcSizeBase32— Calculate the output size needed to encode a given input size for encodeIntoBase32.decodeBase32— `decodeBase32` takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format. If a Uint8Array<ArrayBuffer> is provided as input then a subarray of the input containing the decoded data is returned.encodeBase32— `encodeBase32` takes an input source and encodes it into a base32 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.encodeIntoBase32— `encodeIntoBase32` takes an input source and encodes it as base32 into the output buffer.Uint8Array_— Proxy type of {@code Uint8Array<ArrayBuffer>} or {@code Uint8Array} in TypeScript 5.7 or below respectively.