TestTOTPCode (open)
Test if a TOTP code matches the expected value
Syntax
LOADLIB "wh::util/otp.whlib";
RECORD FUNCTION TestTOTPCode(STRING secret, STRING code, RECORD options)Parameters
STRING secretThe key to use (raw byte value)
STRING codeExpected code
RECORD optionsOptions
INTEGER allowdriftAllowed drift in seconds. Rounded down to whole intervals, defaults to 30
INTEGER digitsThe length of the resulting password, range [6-8], defaults to 6
STRING hmacThe HMAC algorithm to use, defaults to "HMAC:SHA-1"
INTEGER intervalThe interval to use in seconds, defaults to 30
DATETIME nowCurrent time
Return value
RECORDMatch result
INTEGER driftintervalsDrift in interval steps
INTEGER driftsecondsDrift in seconds
BOOLEAN successWhether a match was found