/multibase

100% Kotlin Multiplatform Multibase Encoder/Decoder

Primary LanguageKotlinMIT LicenseMIT

multi^2_base

A-SIT Plus Official GitHub license Maven Central

Kotlin Kotlin Java

multi2base = 100% pure Kotlin Multiplatform Multibase Encoder/Decoder

This is combined a port of

This project includes the original Protocol Labs repository as a git submodule for it's test vectors, but does not incorporate any code form it in releases.

multi2base supports the following multibase encodings:

  • BASE10
  • BASE16
  • BASE16_UPPER
  • BASE32
  • BASE32_UPPER
  • BASE32_PAD
  • BASE32_PAD_UPPER
  • BASE32_HEX
  • BASE32_HEX_UPPER
  • BASE32_HEX_PAD
  • BASE32_HEX_PAD_UPPER
  • BASE58_FLICKR
  • BASE58_BTC
  • BASE64
  • BASE64_URL
  • BASE64_PAD
  • BASE64_URL_PAD

Full documentation.

Using in your Projects

This library is available at maven central.

Gradle

dependencies {
    implementation("at.asitplus:multibase:$version")
}

Note: This library exposes Matthew Nelson's Base64, Base32, and Base16 encoders as API dependency!

API

Simply MultiBase.decode(from_multibase_string) or MutltiBase.encode(Base.<desired>, any_byte_array) to a multibase string or use the extension functions:

  • multibaseString.multibaseDecode()
  • byteArray.multibaseEncode(Base.<desired>)

Note: Base10 and Base58 don't perform well. Only use those on small (<4KiB) data.

UVarInt works similarly straight-forward:

  • Create: UVarInt(1337u)
  • Decode: someVarIntByteArray.varIntDecode() or UVarInt.fromByteArray(someVarIntByteArray)
  • Encode: aUVarInt.encodeToByteArray()

'Nuff said!

Contributing

External contributions are greatly appreciated! Just be sure to observe the contribution guidelines (see CONTRIBUTING.md).




The MIT license does not apply to the project logo and the A-SIT logo, as these are the sole property of A-SIT/A-SIT Plus GmbH and may not be used without explicit permission!