TOTP class

Time-based One-Time Password (RFC 6238).

Constructors

TOTP({required String secret, int digits = 6, OTPAlgorithm algorithm = OTPAlgorithm.sha1, int period = 30})
Creates a TOTP instance from a Base32-encoded secret.
TOTP.fromBytes({required Uint8List secret, int digits = 6, OTPAlgorithm algorithm = OTPAlgorithm.sha1, int period = 30})
Creates a TOTP instance from raw secret bytes.

Properties

algorithm → OTPAlgorithm
Hash algorithm used.
no setter
digits → int
Number of digits in the generated code.
no setter
hashCode → int
The hash code for this object.
no setterinherited
period → int
Time step in seconds (default: 30).
final
remaining → int
Seconds remaining until the current code expires.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

at(DateTime time) → String
Generates the OTP code for the given time.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
now() → String
Generates the current OTP code.
toString() → String
A string representation of this object.
inherited
verify(String code, {DateTime? time, int window = 1}) → bool
Verifies the code against the given time (or now).

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

format(String code) → String
Formats a code with a space in the middle for readability.