Yet Another OTP generator
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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