Upgrade dependencies

This commit is contained in:
2026-03-12 11:25:47 +01:00
parent baf897e9e3
commit 8b0f24c6b4
3 changed files with 13 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ import kotlin.time.Duration.Companion.seconds
import kotlin.time.Instant
class TOTP(
val function: HashFunction = SHA1,
val function: HashFunction = SHA1(),
val length: Int = 6,
val period: Duration = 30.seconds,
) {
@@ -17,13 +17,13 @@ class TOTP(
return hotp.generate(secret, counter(instant))
}
fun verify(secret: ByteArray, instant: Instant, otp: String): Boolean {
return generate(secret, instant) == otp
}
private fun counter(instant: Instant): Long {
val ms = instant.toEpochMilliseconds()
val d = period.inWholeMilliseconds
return ms / d
}
fun verify(secret: ByteArray, instant: Instant, otp: String): Boolean {
return generate(secret, instant) == otp
}
}