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 secret

The key to use (raw byte value)

STRING code

Expected code

RECORD options

Options

INTEGER allowdrift

Allowed drift in seconds. Rounded down to whole intervals, defaults to 30

INTEGER digits

The length of the resulting password, range [6-8], defaults to 6

STRING hmac

The HMAC algorithm to use, defaults to "HMAC:SHA-1"

INTEGER interval

The interval to use in seconds, defaults to 30

DATETIME now

Current time

Return value

RECORD

Match result

INTEGER driftintervals

Drift in interval steps

INTEGER driftseconds

Drift in seconds

BOOLEAN success

Whether a match was found