12345678910111213 |
- package com.chameth.yaotp.algos
-
- import java.nio.ByteBuffer
-
- data class TotpParams(val hotpParams: HotpParams, val startTime: Long = 0, val step: Int = 30)
-
- fun totp(totpParams: TotpParams, currentTime: Long = currentTime()) = hotp(totpParams.hotpParams, count(totpParams.startTime, totpParams.step, currentTime).toByteArray())
-
- internal fun count(startTime: Long, step: Int, currentTime: Long) = (currentTime - startTime) / step
-
- internal fun currentTime() = System.currentTimeMillis() / 1000
-
- internal fun Long.toByteArray() = ByteBuffer.allocate(java.lang.Long.BYTES).putLong(this).array()
|