TotpGeneratorContext
public final class TotpGeneratorContext: OtpGeneratorContext
A class of Generator used to generate a time based one-time password (TOTP).
-
A value between 10 and 300 representing the number of seconds the password is valid. Default is 30.
Declaration
Swift
fileprivate(set) public var period: TimeInterval
-
Construct an instance containing the given secret, password length, algorithm and period the password is valid for. Initialization returns
nil
if digits length is invalid or period outside the range.Declaration
Swift
public init?(secret: String, digits: Int = 6, algorithm: HmacAlgorithm = HmacAlgorithm.sha1, period: TimeInterval = 30)
-
This method generates a time based one-time password valid for a given period.
Declaration
Swift
public func create(_ timeInterval: TimeInterval = Date().timeIntervalSince1970) -> String?
-
Calculates the remaining time for a given period in seconds, based on
GMT: Thu, 01 Jan 1970 00:00:00 GMT
.Declaration
Swift
public static func remainingTime(_ timeInterval: TimeInterval = 30) -> Int?