Пример #1
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            var tfA    = new TwoFactorAuthenticator();
            var result = tfA.ValidateTwoFactorPin(txtSecretKey.Text, txtCode.Text);

            MessageBox.Show(result ? "Validated!" : "Incorrect", "Result");
        }
        protected void btnValidate_Click(object sender, EventArgs e)
        {
            var tfa    = new TwoFactorAuthenticator();
            var result = tfa.ValidateTwoFactorPin(Request.QueryString["key"], txtCode.Text);

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