multibase
This is combined a port of
Protocol Labs' Kotlin/JVM multibase implementation to Kotlin multiplatform with significant help from Matthew Nelson's awesome encoding library and Uglješa Jovanović's KMP bignum library
Erwin Kok's Kotlin unsigned varint implementation with some streamlining
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.
multi2–base 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
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()
orUVarInt.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!