View Source Base85.Encode (Base85 v0.3.0)
Implements encoding functionality for Base85 encoding.
Summary
Functions
Encodes binary data into a Base85-encoded string.
Encodes binary data into a Base85-encoded string.
Types
@type charset() :: Base85.Charsets.charset()
available character sets
@type encoding_error() ::
:unrecognized_character_set
| :unrecognized_padding
| :invalid_unencoded_length
| :internal_error
encoding errors
options for encoding
@type padding() :: Base85.Padding.padding()
available padding techniques
Functions
@spec encode(binary(), encoding_opts()) :: {:ok, binary()} | {:error, encoding_error()}
Encodes binary data into a Base85-encoded string.
This version returns an :ok
-tuple or :error
-tuple.
Examples
iex> Base85.Encode.encode("some binary data", charset: :safe85, padding: :pkcs7)
{:ok, "N.Xx21Kf++HD3`AI>AZp$Aer7"}
iex> Base85.Encode.encode("123412341234", charset: :zeromq, padding: :none)
{:ok, "f!$Kwf!$Kwf!$Kw"}
iex> Base85.Encode.encode("123", charset: :safe85, padding: :none)
{:error, :invalid_unencoded_length}
Options
binary
- the binary data to encode, must be a multiple of 32-bits long if no padding is used;:charset
- an atom indicating the character set to use for encoding;:padding
- an atom indicating which padding technique to use;
Padding methods and encodings may use additional options.
@spec encode!(binary(), encoding_opts()) :: binary()
Encodes binary data into a Base85-encoded string.
This version returns the value or raises an error.
Examples
iex> Base85.Encode.encode!("some binary data", charset: :safe85, padding: :pkcs7)
"N.Xx21Kf++HD3`AI>AZp$Aer7"
iex> Base85.Encode.encode!("123412341234", charset: :zeromq, padding: :none)
"f!$Kwf!$Kwf!$Kw"
iex> Base85.Encode.encode!("123", charset: :safe85, padding: :none)
** (Base85.InvalidUnencodedLength) raw data had invalid length for padding method none, expected multiple of 4 bytes
Options
binary
- the binary data to encode, must be a multiple of 32-bits long if no padding is used;:charset
- an atom indicating the character set to use for encoding;:padding
- an atom indicating which padding technique to use;
Padding methods and encodings may use additional options.