Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 5.28 KB

File metadata and controls

95 lines (69 loc) · 5.28 KB

multi^2_base

A-SIT Plus Official GitHub license Maven Central

Kotlin Kotlin Java

multi2base = 100% pure Kotlin Multiplatform Multibase Encoder/Decoder

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.

multi2base runs on all KMP targets except watchosDeviceArm64 and 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 on Maven Central.

Gradle

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

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

API

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 is similarly straightforward:

  • 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!