Home

Awesome

Copper Multibase Encoder and Decoder.

A Java implementation of Multibase.

Java 8 CI Maven Central License

Features

Examples

/* encode an input with Base58BTC */
String encoded = Multibase.BASE_58_BTC.encode(byte[]);

/* get decoder instance initialized with all supported bases */
var decoder = MultibaseDecoder.getInstance();

/* get decoder initialized with custom base(s) */
var decoder = MultibaseDecoder.getInstance(cbases...);

/* decode */
byte[] decoded = decoder.decode(encoded);

/* or check if base is supported  */
Multibase base = decoder.getBase(encoded).orElseThrow(() -> new IllegalArgumentException("Unsupported base."));
byte[] decoded = base.decode(encoded);

/* or directy when only one base is supported */
byte[] decoded = Multibase.BASE_58_BTC.decode(encoded);

/* check if encoded with a base */
if (Multibase.BASE_58_BTC.isEncoded(encoded)) {
  ...
}

/* a cutom base implementation */
var mybase = new Multibase(
                     prefix,   // multibase prefix letter
                     length,   // alphabet length
                     string -> byte[], // decode fnc.
                     byte[] -> string // encode fnc.
                     );

/* encode with a custom base */
String encoded = mybase.encode(byte[]);

/* directly decode with a custom base */
byte[] decoded = mybase.decode(encoded);

/* get decoder initialized with a custom base */
var decoder = MultibaseDecorer.getInstance(mybase, ...);

Installation

Maven

<dependency>
    <groupId>com.apicatalog</groupId>
    <artifactId>copper-multibase</artifactId>
    <version>1.0.0</version>
</dependency>

Documentation

javadoc

Contributing

All PR's welcome!

Building

Fork and clone the project repository.

> cd copper-multibase
> mvn clean package

Resources