decodeBase32

import { decodeBase32 } from "jsr:@ende/encoding/unstable-base32";

function ยท experimental

function decodeBase32(input: string | Uint8Array_, options: Base32Options = [UNSUPPORTED]): Uint8Array_

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.

input: string | Uint8Array_

The input source to decode.

options: Base32Options = [UNSUPPORTED]

The options to use for decoding.

Returns

The decoded Uint8Array<ArrayBuffer>.

Example: Basic Usage

import { assertEquals } from "@ende/assert";
import { decodeBase32 } from "@ende/encoding/unstable-base32";

assertEquals(
  decodeBase32("JBSWY3DPEBLW64TMMQ======", { alphabet: "base32"}),
  new TextEncoder().encode("Hello World"),
);

assertEquals(
  decodeBase32("91IMOR3F41BMUSJCCG======", { alphabet: "base32hex"}),
  new TextEncoder().encode("Hello World"),
);

assertEquals(
  decodeBase32("91JPRV3F41BPYWKCCG======", { alphabet: "base32crockford"}),
  new TextEncoder().encode("Hello World"),
);

Source