
Facilitates encoding and decoding of data using various multibase schemes, including BASE10, BASE16, BASE32, BASE58, BASE64. Offers straightforward API functions for multibase string conversions and UVarInt operations.
This project combines:
This project includes the original Protocol Labs repository as a git submodule for its test vectors but does not incorporate any code from it in releases.
multi2–base runs on all KMP targets except watchosDeviceArm64 and supports the following multibase encodings:
This library is available on Maven Central.
dependencies {
implementation("at.asitplus:multibase:$version")
}Note: This library exposes Matthew Nelson's Base64, Base32, and Base16 encoders as an API dependency!
Encode and decode multibase values with the extension functions:
val encoded = byteArray.multibaseEncode(MultiBase.Base.BASE58_BTC)
val decoded = encoded.multibaseDecode()For a custom alphabet and radix, use the Base-N extensions:
val encoded = byteArray.encodeBaseN(alphabet, radix)
val decoded = encoded.decodeBaseN(alphabet, radix)UVarInt supports values from 0 through 2^63 - 1:
val encoded = UVarInt(1337uL).encodeToByteArray()
val decoded = encoded.decodeAsUVarInt()
val (leading, endIndex) = bytes.decodeLeadingUVarInt(startIndex)decodeAsUVarInt requires the UVarInt to consume the rest of the array.
decodeLeadingUVarInt instead returns the decoded value and the first index after it.
The corresponding functions are UVarInt.fromByteArrayStrict and
UVarInt.fromByteArrayPermissive; varIntDecode and UVarInt.fromByteArray are deprecated.
'Nuff said!
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!
This project combines:
This project includes the original Protocol Labs repository as a git submodule for its test vectors but does not incorporate any code from it in releases.
multi2–base runs on all KMP targets except watchosDeviceArm64 and supports the following multibase encodings:
This library is available on Maven Central.
dependencies {
implementation("at.asitplus:multibase:$version")
}Note: This library exposes Matthew Nelson's Base64, Base32, and Base16 encoders as an API dependency!
Encode and decode multibase values with the extension functions:
val encoded = byteArray.multibaseEncode(MultiBase.Base.BASE58_BTC)
val decoded = encoded.multibaseDecode()For a custom alphabet and radix, use the Base-N extensions:
val encoded = byteArray.encodeBaseN(alphabet, radix)
val decoded = encoded.decodeBaseN(alphabet, radix)UVarInt supports values from 0 through 2^63 - 1:
val encoded = UVarInt(1337uL).encodeToByteArray()
val decoded = encoded.decodeAsUVarInt()
val (leading, endIndex) = bytes.decodeLeadingUVarInt(startIndex)decodeAsUVarInt requires the UVarInt to consume the rest of the array.
decodeLeadingUVarInt instead returns the decoded value and the first index after it.
The corresponding functions are UVarInt.fromByteArrayStrict and
UVarInt.fromByteArrayPermissive; varIntDecode and UVarInt.fromByteArray are deprecated.
'Nuff said!
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!