RaiEx v0.2.0 RaiEx.Tools.Base32 View Source
This module provides functions for dealing with encoding and decoding, RaiDice base32.
Link to this section Summary
Functions
Returns true if the binary can be encoded into base32
Returns a duplexed map of character <-> bitstring mappings
Same as decode!
, except returns a results tuple
Decodes a base32 string into its bitstring form
Same as encode!
, except returns a results tuple
Encodes a bitstring/binary into its base32 form
Link to this section Functions
Returns true if the binary can be encoded into base32.
Returns a duplexed map of character <-> bitstring mappings.
Example
%{"1" => <<0::size(5)>>, <0::size(5)>> => "1"}
Same as decode!
, except returns a results tuple.
Examples
iex> decode("34bmipzf")
{:ok, <<8, 147, 56, 91, 237>>}
iex> decode("bmg2")
{:error, :badarg}
Decodes a base32 string into its bitstring form.
Raises ArgumentError
if the string is invalid.
Examples
iex> decode!("34bmipzf")
<<8, 147, 56, 91, 237>>
iex> decode!("bmg2")
** (Elixir.ArgumentError)
Same as encode!
, except returns a results tuple.
Examples
iex> encode(<<8, 147, 56, 91, 237>>)
{:ok, "34bmipzf"}
iex> encode(<<8, 5>>)
{:error, :badarg}
Encodes a bitstring/binary into its base32 form.
Raises ArgumentError
if the bitstring/binary is invalid.
Examples
iex> encode(<<8, 147, 56, 91, 237>>)
"34bmipzf"
iex> encode(<<8, 5>>)
** (Elixir.ArgumentError)