too tired to write a detailed commit message or split into self-explanatory commits
40 lines
724 B
Markdown
40 lines
724 B
Markdown
# otp-kt
|
|
|
|
`otp-kt` is a Kotlin Multiplatform library that provides common [One-Time Password](https://en.wikipedia.org/wiki/One-time_password) algorithms.
|
|
|
|
Supported algorithms:
|
|
- HOTP
|
|
- TOTP
|
|
|
|
## Installation
|
|
|
|
Add the following to your `build.gradle.kts`.
|
|
|
|
```kotlin
|
|
repositories {
|
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
|
}
|
|
|
|
dependencies {
|
|
implementation("com.infendro:otp:1.3.0")
|
|
}
|
|
```
|
|
|
|
## Usage
|
|
|
|
```kotlin
|
|
fun main() {
|
|
// create TOTP instance
|
|
val totp = TOTP(
|
|
function = SHA1,
|
|
length = 6,
|
|
period = 30.seconds,
|
|
)
|
|
|
|
// generate and verify OTP
|
|
val now = System.now()
|
|
val otp = totp.generate(<secret>, now)
|
|
totp.verify(<secret>, now, otp)
|
|
}
|
|
```
|