Base32-Crockford v0.1.0 Base32Crockford View Source

Base32-Crockford: base-32 encoding for expressing integer numbers in a form that can be conveniently and accurately transmitted between humans and computer systems.

https://www.crockford.com/wrmg/base32.html

Link to this section Summary

Functions

Decodes base32-crockford encoded string into integer number

Encodes an integer number into base32-crockford encoded string

Link to this section Functions

Link to this function decode(binary, opts \\ []) View Source
decode(binary(), keyword()) :: {:ok, integer()} | :error

Decodes base32-crockford encoded string into integer number.

Examples

iex> Base32Crockford.decode("XSNJG0")
{:ok, 1000000000}

iex> Base32Crockford.decode("XSN-JG0")
{:ok, 1000000000}

iex> Base32Crockford.decode("10*", check_symbol: true)
{:ok, 32}

iex> Base32Crockford.decode("10~", check_symbol: true)
:error
Link to this function encode(number, opts \\ []) View Source
encode(integer(), keyword()) :: binary()

Encodes an integer number into base32-crockford encoded string.

Examples

iex> Base32Crockford.encode(1_000_000_000)
"XSNJG0"

iex> Base32Crockford.encode(1_000_000_000, partition_length: 2)
"XS-NJ-G0"

iex> Base32Crockford.encode(1_000_000_000, partition_length: 3)
"XSN-JG0"

iex> Base32Crockford.encode(32, check_symbol: true)
"10*"