Yet Another OTP generator
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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 }