Beispiel #1
0
        private void btGenerate_Click(object sender, EventArgs e)
        {
            Key = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 10);

            keyTextBox.Text = Key;

            TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
            var setupInfo = tfa.GenerateSetupCode("Test Two Factor", "*****@*****.**", Key, 300, 300);

            string qrCodeImageUrl       = setupInfo.QrCodeSetupImageUrl;
            string manualEntrySetupCode = setupInfo.ManualEntryKey;

            qrBox.Image   = setupInfo.QrCodeImage;
            setupBox.Text = setupInfo.ManualEntryKey;
        }
Beispiel #2
0
        private void btMatch_Click(object sender, EventArgs e)
        {
            TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
            var result = tfa.ValidateTwoFactorPIN(Key, inputBox.Text);

            if (result)
            {
                resultLabel.Text      = inputBox.Text + " is a valid PIN at UTC time " + DateTime.UtcNow.ToString();
                resultLabel.ForeColor = Color.Green;
            }
            else
            {
                resultLabel.Text      = inputBox.Text + " is not a valid PIN at UTC time " + DateTime.UtcNow.ToString();
                resultLabel.ForeColor = System.Drawing.Color.Red;
            }
        }