generateTOTPCodeString method
- String secret,
- int time,
- {int length: 6,
- int interval: 30,
- Algorithm algorithm: Algorithm.SHA256,
- bool isGoogle: false}
Generates a Time-based one time password code and return as a 0 padded string.
Takes current time in milliseconds, converts to seconds and devides it by interval to get a code every iteration of the interval. A interval of 1 will be the same as if passing time into the HOTPCode function..
Optional parameters to change the length of the code provided (default 6), interval (default 30), and hashing algorithm (default SHA1) These settings are defaulted to the RFC standard but can be changed.
Implementation
static String generateTOTPCodeString(String secret, int time,
{int length = 6,
int interval = 30,
Algorithm algorithm = Algorithm.SHA256,
bool isGoogle = false}) {
var code =
'${generateTOTPCode(secret, time, length: length, interval: interval, algorithm: algorithm, isGoogle: isGoogle)}';
return code.padLeft(length, '0');
}