-
Notifications
You must be signed in to change notification settings - Fork 128
Home
ahwm edited this page Dec 5, 2019
·
4 revisions
Welcome to the GoogleAuthenticator wiki!
Generate a new setup code
using Google.Authenticator;
string key = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
SetupCode setupInfo = tfa.GenerateSetupCode("Test Two Factor", "[email protected]", key, false, 300);
string qrCodeImageUrl = setupInfo.QrCodeSetupImageUrl;
string manualEntrySetupCode = setupInfo.ManualEntryKey;
imgQrCode.ImageUrl = "data:image/png;base64," + qrCodeImageUrl;
lblManualSetupCode.Text = manualEntrySetupCode;
// verify
TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
bool result = tfa.ValidateTwoFactorPIN(key, txtCode.Text);