thirtytwo

Package Version Hex Docs

Base32 encoding and decoding for Gleam, supporting all major variants. Works on both Erlang and JavaScript targets.

Supported Variants

VariantEncodeDecodeNotes
RFC 4648encodedecodeStandard alphabet, optional padding, case-insensitive decode
base32hexhex_encodehex_decodePreserves sort order, optional padding, case-insensitive decode
Crockfordcrockford_encodecrockford_decodeOptional check digit, alias normalization (O→0, I/L→1), hyphens ignored
z-base-32z_base_32_encodez_base_32_decodeHuman-oriented, no padding, case-sensitive
Geohashgeohash_encodegeohash_decodeNo padding, case-sensitive

Usage

gleam add thirtytwo
import thirtytwo

// RFC 4648
thirtytwo.encode(<<"wibble":utf8>>, padding: True)
// -> "O5UWEYTMMU======"

thirtytwo.decode("O5UWEYTMMU======")
// -> Ok(<<"wibble":utf8>>)

// Crockford with check digit
thirtytwo.crockford_encode(<<255>>, check: True)
// -> "ZW~"

thirtytwo.crockford_decode("ZW~", check: True)
// -> Ok(<<255>>)

// Geohash
thirtytwo.geohash_encode(<<"wibble":utf8>>)
// -> "fxnq4smddn"

Further documentation can be found at https://hexdocs.pm/thirtytwo.

Search Document