baf897e9e38e5656f7a3ec40ea197b2f4043b274
All checks were successful
/ publish (push) Successful in 2m38s
Reviewed-on: Infendro/otp-kt#2
otp-kt
otp-kt is a Kotlin Multiplatform library that provides common One-Time Password algorithms.
Supported algorithms:
- HOTP
- TOTP
Installation
Add the following to your build.gradle.kts.
repositories {
maven("https://git.infendro.com/api/packages/Infendro/maven")
}
dependencies {
implementation("com.infendro:otp:1.3.0")
}
Usage
fun main() {
// create TOTP instance
val totp = TOTP(
function = SHA1,
length = 6,
period = 30.seconds,
)
// generate and verify OTP
val secret = "...".encodeToByteArray()
val time = System.now()
val otp = totp.generate(secret, time)
totp.verify(secret, time, otp)
}
Description
Languages
Kotlin
100%