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