update dependencies, use common plugin
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
package com.infendro.otp
|
||||
|
||||
import com.infendro.hash.HashFunction
|
||||
import com.infendro.hash.SHA1
|
||||
import com.infendro.hash.sha1.SHA1
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.Instant
|
||||
|
||||
class TOTP(
|
||||
function: HashFunction = SHA1,
|
||||
length: Int = 6,
|
||||
val function: HashFunction = SHA1,
|
||||
val length: Int = 6,
|
||||
val period: Duration = 30.seconds,
|
||||
) {
|
||||
val hotp = HOTP(function, length)
|
||||
private val hotp = HOTP(function, length)
|
||||
|
||||
fun verify(
|
||||
secret: ByteArray,
|
||||
secret: UByteArray,
|
||||
instant: Instant,
|
||||
otp: String,
|
||||
): Boolean {
|
||||
@@ -22,13 +22,10 @@ class TOTP(
|
||||
}
|
||||
|
||||
fun generate(
|
||||
secret: ByteArray,
|
||||
secret: UByteArray,
|
||||
instant: Instant,
|
||||
): String {
|
||||
return hotp.generate(
|
||||
secret,
|
||||
counter(instant)
|
||||
)
|
||||
return hotp.generate(secret, counter(instant))
|
||||
}
|
||||
|
||||
private fun counter(
|
||||
|
||||
Reference in New Issue
Block a user