import { createBaseConverter } from "https://deno.land/x/libauth@v2.0.0-alpha.6/src/lib/format/base-convert.ts";
Create a BaseConverter, exposing methods for encoding and decoding
Uint8Array
s using bitcoin-style padding: each leading zero in the input is
replaced with the zero-index character of the alphabet
, then the remainder
of the input is encoded as a large number in the specified alphabet.
For example, using the alphabet 01
, the input [0, 15]
is encoded 01111
– a single 0
represents the leading padding, followed by the base2 encoded
0x1111
(15). With the same alphabet, the input [0, 0, 255]
is encoded
0011111111
- only two 0
characters are required to represent both
leading zeros, followed by the base2 encoded 0x11111111
(255).
This is not compatible with RFC 3548
's Base16
, Base32
, or Base64
.
If the alphabet is malformed, this method returns the error as a string
.