diff --git a/Google.Authenticator/TwoFactorAuthenticator.cs b/Google.Authenticator/TwoFactorAuthenticator.cs index 2436f68..60b3c0c 100644 --- a/Google.Authenticator/TwoFactorAuthenticator.cs +++ b/Google.Authenticator/TwoFactorAuthenticator.cs @@ -190,14 +190,18 @@ private string GenerateHashedCode(byte[] key, long iterationNumber, int digits = private long GetCurrentCounter(DateTime now, DateTime epoch, int timeStep) => (long) (now - epoch).TotalSeconds / timeStep; - public bool ValidateTwoFactorPIN(string accountSecretKey, string twoFactorCodeFromClient) => - ValidateTwoFactorPIN(accountSecretKey, twoFactorCodeFromClient, DefaultClockDriftTolerance); + public bool ValidateTwoFactorPIN( + string accountSecretKey, + string twoFactorCodeFromClient, + bool secretIsBase32 = false) => + ValidateTwoFactorPIN(accountSecretKey, twoFactorCodeFromClient, DefaultClockDriftTolerance, secretIsBase32); public bool ValidateTwoFactorPIN( string accountSecretKey, string twoFactorCodeFromClient, - TimeSpan timeTolerance) - => GetCurrentPINs(accountSecretKey, timeTolerance).Any(c => c == twoFactorCodeFromClient); + TimeSpan timeTolerance, + bool secretIsBase32 = false) => + GetCurrentPINs(accountSecretKey, timeTolerance, secretIsBase32).Any(c => c == twoFactorCodeFromClient); public string GetCurrentPIN(string accountSecretKey, bool secretIsBase32 = false) => GeneratePINAtInterval(accountSecretKey, GetCurrentCounter(), secretIsBase32: secretIsBase32);