Yet Another OTP generator
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Otp.kt 355B

12345678
  1. package com.chameth.yaotp.algos
  2. import kotlin.math.max
  3. data class Otp(val otp: String, val expiresAt: Long?)
  4. internal fun newOtp(otp: Int, targetLength: Int, expiresAt: Long? = null) = Otp(pad(otp, targetLength), expiresAt)
  5. internal fun pad(otp: Int, targetLength: Int) = with(otp.toString()) { "0".repeat(max(0, targetLength - length)) + this }