e-CryptIt Engine Xojo Plugin

Einhugur_2FA_TOTP.Validate Method

Validates value against given secret key and current time. This variation validates value for standard implementation.

shared Validate(
   secretKey as String,
   value as String) as Boolean

Parameters

secretKey
The secret key.

Secret keys are represented in various of ways and the plugin will preprocess them correctly to take all representations.

For example then all of the following keys are equal:
N7P7TWR3Q5WUA2XG
N7P7 TWR3 Q5WU A2XG
n7P7 tWR3 q5WU a2XG
value
The value (6 digits entered by user or generated by GenerateValue).

Returns

Boolean
True if validation passed, else false.

Remarks

This function can throw InvalidArgumentException.


try
    var outSecondsRemaining as Integer
    var isValid as Boolean = Einhugur_2FA_TOTP.Validate(tbSecretKey.Text, tbPinValue.Text)
   
    if isValid then
       MessageBox "The pin is valid"
    else
       MessageBox "The pin is not valid"
    end if
   
catch e as InvalidArgumentException
// We can get exception if passing in empty secret or invalid secret.
MessageBox(e.Message)
end try


See Also

Einhugur_2FA_TOTP Class