public IActionResult Index() { #region Example 1 - All Parameters var paramDictionary = new Dictionary <string, string>(); paramDictionary.Add("param1", 1234.ToString()); paramDictionary.Add("param2", "Hello World!"); ViewBag.encryptedRouteParam1 = CryptoNew.Encrypt(paramDictionary); #endregion #region Example 2 - Crypto values combined with visible values var person = new Person() { PersonId = 1234, FirstName = "Nandip", LastName = "Makwana" }; paramDictionary = new Dictionary <string, string>(); paramDictionary.Add("SECRETPERSONID", person.PersonId.ToString()); paramDictionary.Add("SECRETPARAM2", 5678.ToString()); ViewBag.encryptedRouteParam2 = CryptoNew.Encrypt(paramDictionary); #endregion return(View(person)); }
protected void btnIniciarSesion_Click(object sender, EventArgs e) { Apoderado apoderado = new Apoderado(); if (!apoderado.ReadApoderado(txtUsuario.Text)) { apoderado = null; lblMensajeError.Text = "Usuario y/o contraseña inválido."; } else if (!CryptoNew.VerifyPassword(txtContraseña.Text, apoderado.Passwd)) { apoderado = null; lblMensajeError.Text = "Usuario y/o contraseña inválido."; } else { if (apoderado.Representante == 1) { Session["userAdmin"] = apoderado; Response.Redirect("~/Index.aspx"); } else { Session["user"] = apoderado; Response.Redirect("~/Index.aspx"); } } }
public bool ContainsPrefix(string prefix) { if (_values == null) { if (string.IsNullOrEmpty(_encryptedParameters)) { _values = new Dictionary <string, string>(); } else { _values = CryptoNew.DecryptInKeyValue(_encryptedParameters); } } return(_values.ContainsKey(prefix.ToUpper())); }
protected void btnActualizar_Click(object sender, EventArgs e) { try { if (txtNewPass.Text == txtRePass.Text) { var uri = new Uri(HttpContext.Current.Request.Url.ToString()); var query = HttpUtility.ParseQueryString(uri.Query); string usuario = query.Get("us").ToString(); new Apoderado().UpdatePass(usuario, CryptoNew.CreatePasswordHash(txtNewPass.Text)); Response.Redirect("Index.aspx"); } else { lblError.Text = "Por favor, confirmar que la contraseña sea la misma en ambas casillas"; } } catch (Exception) { throw; } }