sixtytwo

Base62 encoding and decoding for Gleam, targeting both Erlang and JavaScript.

Uses the standard 0-9A-Za-z alphabet with Bitcoin/base-x style leading zero preservation, compatible with cryptocoinjs/base-x.

Examples

sixtytwo.encode(<<"hello":utf8>>)
// -> "7tQLFHz"

sixtytwo.decode("7tQLFHz")
// -> Ok(<<"hello":utf8>>)

Values

pub fn decode(input: String) -> Result(BitArray, Nil)

Decode a base62 string. Returns Error(Nil) on invalid input.

pub fn encode(input: BitArray) -> String

Encode a bit array using base62. The input must be byte-aligned. Leading zero bytes are preserved as 0 characters in the output.

Search Document