HotpGeneratorContext

public final class HotpGeneratorContext : OtpGeneratorContext

A class of Generator used to generate a counter based one-time password (HOTP).

  • Construct an instance containing the given secret, password length and algorithm. Initializating returns nil if digits length is invalid.

    Declaration

    Swift

    public init?(secret: String, digits: Int = 6, algorithm: HmacAlgorithm = HmacAlgorithm.sha1, counter: Int)

    Parameters

    secret

    The secret key used to generate the password.

    digits

    A value of 6 or 8 representing the length of the password to be generated. The default is 6.

    algorithm

    The algorithm used to generate the password. The default is HmacAlgorithm.SHA1.

    counter

    An initial value of the counter.

  • This method generates a one-time password.

    Declaration

    Swift

    public func create() -> String?

    Return Value

    A String of the one-time password or nil.