Branca is a secure alternative to JWT, This implementation is written in Kotlin and implements the branca token specification.
Original Java implementation: jbranca
- Add
jitpack.io
to your repositories list
repositories {
// ...
maven { url 'https://jitpack.io' }
}
- Add library to dependencies list
dependencies {
implementation "com.github.petersamokhin:kbranca:$kbrancaVersion"
}
Latest version: https://github.com/petersamokhin/kbranca/releases/latest
val key = "SecretKeyYouShouldNeverCommit!!!" // exactly 32 chars
val factory = BrancaTokenFactory(key)
val plaintext = """{"key": "example_value"}"""
val encoded = factory.encode(plaintext.toByteArray())
val decoded = factory.decode(encoded)
assertEquals(plaintext, String(decoded))