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

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 }