Yet Another OTP generator
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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 }