update README
This commit is contained in:
33
README.md
33
README.md
@@ -1,16 +1,19 @@
|
||||
# Kotlin OTP
|
||||
# otp-kt
|
||||
|
||||
This library provides various [One-Time Password](https://en.wikipedia.org/wiki/One-time_password)
|
||||
implementations in Kotlin Multiplatform.
|
||||
`otp-kt` is a Kotlin Multiplatform library that provides common one-time password implementations.
|
||||
|
||||
## Features
|
||||
Supported implementations:
|
||||
- HOTP
|
||||
- TOTP
|
||||
|
||||
* [HOTP](https://en.wikipedia.org/wiki/HMAC-based_one-time_password)
|
||||
* [TOTP](https://en.wikipedia.org/wiki/Time-based_one-time_password)
|
||||
* Multiplatform support
|
||||
* JVM
|
||||
* JavaScript
|
||||
* Native (Linux)
|
||||
## Targets
|
||||
|
||||
| Target | Status |
|
||||
|------------------|---------------|
|
||||
| JVM | Supported |
|
||||
| JavaScript | Supported |
|
||||
| Native (Linux) | Supported |
|
||||
| Native (Windows) | Not Supported |
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -22,21 +25,23 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.infendro:otp:1.1.1")
|
||||
implementation("com.infendro:otp:1.2.1")
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```kotlin
|
||||
import com.infendro.hash.SHA1
|
||||
import com.infendro.hash.sha1.SHA1
|
||||
import com.infendro.otp.SecretGenerator
|
||||
import com.infendro.otp.TOTP
|
||||
import com.infendro.random.csprng.CSPRNG
|
||||
import kotlin.time.Clock.System.now
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
fun main() {
|
||||
// create a TOTP instance using SHA1, a length of 6, and a period of 30 seconds
|
||||
// create a SecretGenerator and TOTP instance
|
||||
val generator = SecretGenerator(CSPRNG.HMAC(SHA1))
|
||||
val totp = TOTP(
|
||||
function = SHA1,
|
||||
length = 6,
|
||||
@@ -44,7 +49,7 @@ fun main() {
|
||||
)
|
||||
|
||||
// generate a secret using SHA1
|
||||
val secret = SecretGenerator.generate(SHA1)
|
||||
val secret = generator.generate()
|
||||
|
||||
// generate an OTP
|
||||
val otp = totp.generate(secret, now())
|
||||
|
||||
Reference in New Issue
Block a user