protected void btnOK_Click(object sender, EventArgs e) { string secret = (string)Session["Secret"]; string identity = (string)Session["Identity"]; byte[] secretByte = (byte[])Session["SecretByte"]; GAuthenticator gauth = new GAuthenticator(); gauth.Secret = secretByte; gauth.Identity = identity; int code; int.TryParse(txtCodigo.Text, out code); if (gauth.OneTimePassword == code) { ltlResult.Text = "Sucesso! Codigo correto!"; } else { ltlResult.Text = "Erro! Codigo incorreto!"; } }
protected void btnSalvar_Click(object sender, EventArgs e) { if (txtIdentity.Text.Length > 0) { string secret = txtSecret.Text; string identity = txtIdentity.Text; GAuthenticator gauth = new GAuthenticator(); gauth.QRCodeSize = 200; gauth.Identity = identity; gauth.Issuer = "www.csharpbrasil.com.br"; gauth.setSecretKey(secret); imgQRCode.ImageUrl = gauth.QRCodeUrl; imgQRCode.DataBind(); Panel1.Visible = true; } }