/idris-multibase

Self-identifying base encodings in Idris

Primary LanguageIdrisGNU General Public License v3.0GPL-3.0

Idris-Multibase

This is an implementation of Multibase in Idris.

This can be used to encode and decode strings in different bases, such as 1, binary, octal, decimal, hexadecimal, 32bitshex, 58bits, and 64bits.

Usage

The API exposes two functions:

encode : BaseSymbol n -> String -> String

This function takes a target base and an arbitrary string as input, and converts the string using the given base.

decode : String -> Either (MultibaseError Char) String

This function decodes a string that has been encoded with the multibase format. It will return MultibaseError if the format is not respected.

See Tests/Multibase.idr for examples.

Installation

  1. Clone the project and cd into the project dir.

  2. Compile it:

    idris --install idris-multibase.ipkg
    
  3. Import Data.Multibase and start using encode and decode.