View Source Base45 (base45 v0.1.1)

A library to encode and decode binaries using the base 45 encoding scheme (specified in RFC 9285).

Link to this section Summary

Functions

Decode Base45 strings to binary data. Raises an exception NilValuesError if the string is not valid Base45.

Decode Base45 strings to binary data. Returns nil if the string is not valid Base45.

Encode binary data as Base45

Examples

  iex> Base45.encode("Hello")
  "%69 VDL2"

  iex(1)> Base45.encode(<<0, 1, 127, 129, 255>>)
  "100G5GU5"

Encodes a file (which must be open, the argument has to be a file handle or an atom such as :stdio)

Link to this section Functions

@spec decode!(String.t()) :: binary()

Decode Base45 strings to binary data. Raises an exception NilValuesError if the string is not valid Base45.

examples

Examples

 iex> Base45.decode!("%69 VDL2")
 "Hello"

 iex(1)> Base45.decode!("===")
 ** (NilValuesError) nil value(s)
@spec decode(String.t()) :: binary()

Decode Base45 strings to binary data. Returns nil if the string is not valid Base45.

examples

Examples

 iex> Base45.decode("%69 VDL2")
 "Hello"

 iex(1)> Base45.decode("100G5GU5")
 <<0, 1, 127, 129, 255>>

 iex(1)> Base45.decode("===")
 nil
@spec encode(binary()) :: String.t()
Encode binary data as Base45

examples

Examples

  iex> Base45.encode("Hello")
  "%69 VDL2"

  iex(1)> Base45.encode(<<0, 1, 127, 129, 255>>)
  "100G5GU5"
@spec encode_file(atom() | pid()) :: String.t()

Encodes a file (which must be open, the argument has to be a file handle or an atom such as :stdio)