Authenticating Users With Encryption Of Passwords

Self-Innovator
Posted by Self-Innovator under ASP.NET category on | Points: 40 | Views : 2009
BtnLogin_Click()
{
string UserId = txtUser.Text.Trim();
Session["UserId"] = UserId;
String Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(),"MD5");
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("spGetUsers", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserId", UserId);
cmd.Parameters.AddWithValue("@Pwd", Pwd);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
if (ds.Tables[0].Rows.Count >0)
{
if(Pwd==ds.Tables[0].Rows[0]["Password"].ToString());
{
Response.Redirect("Home.aspx");
}
else
{
Response.Redirect("Loginaspx");
}
}
}



While Registering Store The Pwd in this Encrypted Format
String Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(),"MD5");

Both are Applicable MD5 or SHA1

Comments or Responses

Login to post response