verify method
Verifies the TOTP value passed in against the current time.
All parameters are mandatory.
TOTP totp = TOTP(secret: 'BASE32ENCODEDSECRET');
totp.now(); // => 432143
// Verify for current time
totp.verify(otp: 432143); // => true
// Verify after 30s
totp.verify(otp: 432143); // => false
Implementation
bool verify({String? otp, DateTime? time}) {
if (otp == null) {
return false;
}
var _time = time ?? DateTime.now();
var _input = Util.timeFormat(time: _time, interval: interval!);
String otpTime = super.generateOTP(input: _input);
return otp == otpTime;
}