public static bool CheckValidate(string key, string code) { string ogKey = GetOrgianalKey(key); var d = new Google.Authenticator.TwoFactorAuthenticator(); return(d.ValidateTwoFactorPIN(ogKey, code)); }
public static string GetRandomSecrect() { string key = getStr(10); var d = new Google.Authenticator.TwoFactorAuthenticator(); var bytes = Encoding.Default.GetBytes(key); string newKey = Base32.ToString(bytes); return(newKey); }
public static SecondFactorAuthSetupCode GenerateSetupCode(string issuer, string username, string secretKey, int qrCodeWidth, int qrCodeHeigt) { Google.Authenticator.TwoFactorAuthenticator tfa = new Google.Authenticator.TwoFactorAuthenticator(); Google.Authenticator.SetupCode setupInfo = tfa.GenerateSetupCode(issuer, username, secretKey, qrCodeWidth, qrCodeHeigt); SecondFactorAuthSetupCode setupCode = new SecondFactorAuthSetupCode() { QrCodeImageUrl = setupInfo.QrCodeSetupImageUrl, SetupCode = setupInfo.ManualEntryKey, }; return(setupCode); }
public static bool ValidatePIN(string secretKey, string pin) { Google.Authenticator.TwoFactorAuthenticator tfa = new Google.Authenticator.TwoFactorAuthenticator(); return(tfa.ValidateTwoFactorPIN(secretKey, pin)); }