View Source BaseX (BaseX v1.3.3)

coding for arbitrary alphabets and block sizes

Summary

Functions

Link to this function

prepare_module(name, alphabet, block_size)

View Source
@spec prepare_module(String.t(), binary() | list() | tuple(), pos_integer()) :: term()

prepare a coding module

Returns the name of the module.

The resulting module will appear in the BaseX namespace and have encode and decode functions available.

Examples:

iex> BaseX.prepare_module("Base2", "01", 4)
BaseX.Base2

iex> BaseX.Base2.encode("Hi!")
"010010000110100100100001"

iex> BaseX.Base2.decode("010010000110100100100001")
"Hi!"

These functions are only suitable for complete messages. Streaming applications should manage their own incomplete message state.

The supplied module name should be both valid (by Elixir rules) and unique. Care should be taken when regenerating modules with the same name.

Alphabets may be defined by {"t","u","p","l","e"}, "string", 'charlist' or ["l","i","s","t"] as desired.