minor refactor
All checks were successful
/ test (pull_request) Successful in 33s

This commit is contained in:
2026-01-30 13:23:32 +01:00
parent 59f7d925a3
commit f5f073168d
2 changed files with 8 additions and 8 deletions

View File

@@ -14,10 +14,6 @@ class HOTP(
) {
private val hmac = HMAC(function)
fun verify(secret: ByteArray, counter: Long, otp: String): Boolean {
return generate(secret, counter) == otp
}
fun generate(secret: ByteArray, counter: Long): String {
require(counter >= 0)
return otp(secret, counter)
@@ -29,4 +25,8 @@ class HOTP(
val otp = (hash.toInt(offset) and 0x7FFFFFFF) % 10.pow(length)
return "$otp".padStart(length, '0')
}
fun verify(secret: ByteArray, counter: Long, otp: String): Boolean {
return generate(secret, counter) == otp
}
}