Skip to content

komputing/KBech32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e470f7d · May 6, 2019

History

11 Commits
Apr 16, 2019
Mar 21, 2019
Apr 16, 2019
Apr 16, 2019
Mar 21, 2019
Mar 21, 2019
Mar 21, 2019
May 6, 2019
Apr 10, 2019
Apr 16, 2019
Apr 16, 2019
May 6, 2019
Mar 21, 2019
Mar 21, 2019
Apr 16, 2019

Repository files navigation

KBech32

KBech32 is a Kotlin multiplatform implementation of the Bech32 address format.

The implementation is heavily based on Bitcoinj Bech32 implementation.

Downloading

This library is available on Jitpack:

In order to download it, firstly include the Jitpack repository on your project build.gradle file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then, insert the following dependency inside your module's build.gradle file:

dependencies {
    implementation 'com.github.komputing.KBech32:core-{platform}:{version}'
}

The latest version is the one published on Jitpack:

Supported platforms

Platform Usage
common Common Kotlin multiplatform projects
jvm Kotlin-JVM modules/projects
js Kotlin-JS modules/projects
native Kotlin-native modules/projects

Usage

// Encode given a human readable part and a byte array
val encoded = Bech32.encode(humanReadablePart = "bc", data = byteArrayOf(1, 2 ,3))

// Encode by wrapping the data into a Bech32Data object
val data = Bech32Data(
  humanReadablePart = "bc",
  data = byteArrayOf(1, 2, 3)
)

// Decode the data
val bech32Value = "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw"
val (humanReadablePart, data) = Bech32.decode(bech32Value)