Tiny Encodings
A companion library to join a few other tiny-* libraries.
This library provides reasonably fast implementations of:
- Base64 Standard Encoding
 - Base64 URL Encoding
 - Base64 Standard Decoding
 - Base64 URL Decoding
 - Hex / Base16 Encoding
 - Hex / Base16 Decoding
 
Where decoding functions take strings and output a Uint8Arrays, and encoding
functions take any buffer type (ArrayBuffer, Uint8Array, other typed arrays,
and DataViews) and output a string.
This library follows the byte order of the host, this means that typed arrays
such as Uint32Array will be encoded in the byte order in its underlying memory
buffer which is host specific. If platform compatibility is required for
multi-byte buffers, see arrayToEndian and arrayFromEndian.
Initially, this library was going to be the reference implementation, as seen
in encoding_reference.ts. However, the reference implementation performance is
abysmal.
This library is no longer automatically published to Deno’s Third Party Modules. Newer versions may appear on deno.land/x, but do not work.
Tiny-encodings mitigates Base64 Malleability by refusing mangled encoded inputs.
Example
// NPM
// import { decodeBase64 } from "@levischuck/tiny-encodings";
// or JSR
// import { decodeBase64 } from "jsr:@levischuck/tiny-encodings";
import { decodeBase64 } from "./index.ts";
decodeBase64("SGVsbG8gd29ybGQ=");
// returns a Uint8Array with the bytes for "Hello world"Where to get it
This library is available on NPM and JSR.
This library is no longer automatically published to Deno’s Third Party Modules. Newer versions may appear on deno.land/x, but do not work.