byte-encodings
Version:
Utilities for encoding and decoding common formats like hex, base64, and varint. Ported from Deno's @std/encoding.
42 lines (39 loc) • 1.1 kB
TypeScript
import { U as Uint8Array_ } from './_types-UoFpvNJp.js';
/**
* Converts data into a base32-encoded string.
*
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
*
* @param data The data to encode.
* @returns The base32-encoded string.
*
* @example Usage
* ```ts
* import { encodeBase32 } from "@std/encoding/base32";
* import { assertEquals } from "@std/assert";
*
* assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
* ```
*/
declare function encodeBase32(data: ArrayBuffer | Uint8Array | string): string;
/**
* Decodes a base32-encoded string.
*
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
*
* @param b32 The base32-encoded string to decode.
* @returns The decoded data.
*
* @example Usage
* ```ts
* import { decodeBase32 } from "@std/encoding/base32";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
* decodeBase32("GZRTMMDDGA======"),
* new TextEncoder().encode("6c60c0"),
* );
* ```
*/
declare function decodeBase32(b32: string): Uint8Array_;
export { Uint8Array_, decodeBase32, encodeBase32 };