close
Skip to main content

@std/encoding@1.0.10
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads44,626/wk
Publisheda year ago (1.0.10)

Utilities for encoding and decoding common formats like hex, base64, and varint

Functions to encode and decode to and from base32 strings.

import { assertEquals } from "@std/assert";
import {
  encodeBase32,
  type Uint8Array_
} from "@std/encoding/unstable-base32";

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

Functions

f
calcSizeBase32(rawSize: number): number

Calculate the output size needed to encode a given input size for encodeIntoBase32.

f
decodeBase32(
input: string | Uint8Array_,
options?: Base32Options
): 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.

f
encodeBase32(
input: string | Uint8Array_ | ArrayBuffer,
options?: Base32Options
): string

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.

f
encodeIntoBase32(
input: string | Uint8Array_ | ArrayBuffer,
output: Uint8Array_,
options?: Base32Options
): number

encodeIntoBase32 takes an input source and encodes it as base32 into the output buffer.

Interfaces

I

Options for encoding and decoding base32 strings.

  • alphabet: Base32Alphabet

    The base32 alphabet. Defaults to "base32"

Type Aliases

T
Base32Alphabet = "base32" | "base32hex" | "base32crockford"

The base32 alphabets.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/encoding

Import symbol

import * as mod from "@std/encoding/unstable-base32";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/encoding/unstable-base32";