update dependencies, use common plugin

This commit is contained in:
2025-12-13 01:44:39 +01:00
parent e8999ae4e4
commit 498a5b5826
6 changed files with 58 additions and 83 deletions

View File

@@ -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(