Skip to content
Kotlin multiplatform implementation of Bech32
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci
.idea
core
gradle
.editorconfig
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

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)
You can’t perform that action at this time.