Skip to main content

TOTP

public class TOTP

  • Utility class to work with time-based OTP feature.

Method Summary​

Parameters
StringgetOTP()Returns OTP. The default expiry time is 30 seconds.
StringgetRemainingSecs()Returns remaining time after which the OTP will expire.
voidsetOTP(totp: String)Sets new OTP.
voidsetRemainingSecond(remainingSecond: Int)Sets remaining time after which the OTP will expire.

Method Details​

getOTP​

public String getOTP()

  • Returns an OTP that is valid for 30 seconds. If this method is called multiple times within the 30-second window, the same OTP value is returned.

getRemainingSecs​

public getRemainingSecs()

  • Returns the remaining time after which the OTP will expire.

setOTP​

public func setOTP(totp: String)

  • Sets new OTP.
Parameters
totpStringThe new TOTP value.

getRemainingSecs​

public func setRemainingSecond(remainingSecond: Int)

  • Sets remaining time after which the OTP will expire.
Parameters
remainingSecondintNumber of seconds remaining after which the TOTP will expire.