Structure
TOTP
Create a one-time password using hash-based message authentication codes and taking uniqueness from the time.
struct TOTP
Overview
let key = SymmetricKey(size: .bits128)
let code = TOTP.SHA1(key: key).generate(time: Date())
print(code) "501247"
See HOTP for hash-based one-time passwords.
Topics
Initializers
init(key: SymmetricKey, digest: OTPDigest, digits: OTPDigits, interval: Int)Initialize the TOTP object.
Instance Methods
func generate(time: Date) -> StringGenerate the TOTP based on a time.func generate(time: Date, range: Int) -> [String]Generates several TOTP’s for a range.
Type Methods
static func generate(key: SymmetricKey, digest: OTPDigest, digits: OTPDigits, interval: Int, time: Date) -> StringCompute the TOTP for the key, time interval and time.
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype