jhn_base (jhn_stdlib v5.12.1)
View SourceA binary data encodinglibrary providing support for a number of bases, algorithms and alphabets. If nothing else is specified the "standard" algorithm is used (with the exception of base85 where only the z85 algorithm currently provided). The algorithm and alphabet to use in encoding or decoding can be specified with options provided to encode/3 and decode/3. Further options are the for the return values of either an iolist or binary, with the exception of the Z-Base-32 algorithm that returns a bitstring.
The following documents are the base for the library
rfc4648: The Base16, Base32, and Base64 Data Encodings * Base32 standard algorithm (standard) * Base32 standard and hex alphabets (standard, hex)
The Base32 wikipage: https://en.wikipedia.org/wiki/Base32 * The Geohash alphabet (geohash)
Crockford's Base32: https://datatracker.ietf.org/doc/draft-crockford-davis-base32-for-humans/ * Crockford base32 algorithm (crockford)
Clockwork: https://github.com/szktty/go-clockwork-base32 * The clockwork algorithm (clockwork)
Z-Base-32: https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt * The Z-Base-32 algorithm (zbase) Does not support binary/iolist deoding since it returns a bitstring only
rfc9285: The Base45 Data Encoding * Base 45 standard algorithm (standard)
ZeroMQ spec:32/Z85: https://rfc.zeromq.org/spec/32/ * The ZeroMQ base85 algorithm (z85)
Summary
Functions
Decodes the data as an iolist using Base default algorithm and alphabet, equivalent to decode(Base, Encoded, []).
Decodes the data as an iolist, bitstring or binary according to the Base. Options binary : returns a binary, not viable for Z-Base-32 iolist : returns an iolist (default) {return_type, binary | iolist}: returns what is specified {algo, Algo}: uses the algorithm Algo for decoding {alphabet, A}: uses the alphabet for the decoding, must be compatible with the algorithm (no checks are done).
Encodes the data as an iolist using Base default algorithm and alphabet, equivalent to encode(Base, Data, []).
Encodes the data as an iolist or binary according to the Base. Options binary : returns a binary, iolist : returns an iolist (default) {return_type, binary | iolist}: returns what is specified {algo, Algo}: uses the algorithm Algo for encoding {alphabet, A}: uses the alphabet for the encoding, must be compatible with the algorithm (no checks are done).
Types
-type algo() :: standard | crockford | clockwork | zbase | z85.
-type alphabet() :: standard | hex | geohash.
-type base() :: 32 | 45 | 85.
-type opt() :: return_type() | {return_type, return_type()} | {alpfabet, alphabet()} | {algo, algo()}.
-type return_type() :: iolist | binary.
Functions
Decodes the data as an iolist using Base default algorithm and alphabet, equivalent to decode(Base, Encoded, []).
Decodes the data as an iolist, bitstring or binary according to the Base. Options binary : returns a binary, not viable for Z-Base-32 iolist : returns an iolist (default) {return_type, binary | iolist}: returns what is specified {algo, Algo}: uses the algorithm Algo for decoding {alphabet, A}: uses the alphabet for the decoding, must be compatible with the algorithm (no checks are done).
Encodes the data as an iolist using Base default algorithm and alphabet, equivalent to encode(Base, Data, []).
Encodes the data as an iolist or binary according to the Base. Options binary : returns a binary, iolist : returns an iolist (default) {return_type, binary | iolist}: returns what is specified {algo, Algo}: uses the algorithm Algo for encoding {alphabet, A}: uses the alphabet for the encoding, must be compatible with the algorithm (no checks are done).