Beauthy SDK
A lightweight Kotlin Multiplatform library for generating TOTP & HOTP one-time passwords.
RFC-compliant TOTP (RFC 6238) and HOTP (RFC 4226) implementation supporting SHA-1, SHA-256, and SHA-512. Zero third-party dependencies — uses only platform-native cryptography.
Download
Kotlin Multiplatform
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.elliuqahs:beauthy-sdk:0.1.0")
}
}
}
Android Only (non-KMP)
dependencies {
implementation("io.github.elliuqahs:beauthy-sdk-android:0.1.0")
}
Usage
Android / KMP Android target
import com.maoungedev.beauthy.core.crypto.*
val generator = TotpGenerator(JvmHmacProvider())
val code = generator.generate(secret = "JBSWY3DPEHPK3PXP", timestampMillis = System.currentTimeMillis())
val remaining = generator.remainingSeconds(System.currentTimeMillis())
code256 = generator.generate(
secret = ,
timestampMillis = System.currentTimeMillis(),
algorithm = HmacAlgorithm.SHA256
)
hotp = generator.generateHotp(secret = , counter = )
(Base32.isValid(userInput)) {
bytes = Base32.decode(userInput)
}
iOS / KMP iOS target
import com.maoungedev.beauthy.core.crypto.*
val generator = TotpGenerator(IosHmacProvider())
val code = generator.generate(secret = "JBSWY3DPEHPK3PXP", timestampMillis = getCurrentTimeMillis())
val remaining = generator.remainingSeconds(getCurrentTimeMillis())
The only difference is the HmacProvider — use JvmHmacProvider() on Android and IosHmacProvider() on iOS. All other APIs are identical.
Supported Platforms
| Platform | HMAC Backend |
|---|
| Android (minSdk 24) | javax.crypto.Mac |
| iOS (arm64, simulatorArm64) | CoreCrypto CCHmac |
Find this library useful?
Support it by joining stargazers for this repository. :star:
License
Copyright 2025 Beauthy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.