Use the formsauthentication class provided by ASP. NET to implement the hash encryption password.
Private void loginbutton_click (Object sender, system. eventargs E)
{
String SQL = string. Format ("select password from administrator where adminid = '{0}', useridbox. Text );
Sqlconnection conn = new sqlconnection (configurationsettings. etettings ["connectionstring"]);
Sqldatareader myreader = new sqlcommand (SQL, Conn). executereader ();
If (myreader. Read ())
{
String hashed =
Formsauthentication. Hashpasswordforstoringinconfigfile (passwordtextbox. Text, "sha1 ");
// Hash the password entered by the user and then use it with the database
Hash ValueFor comparison
If (hash = myreader ["password"]). tostring ())
{
Formsauthentication.
Redirectfromloginpage(Useridbox. Text, true); // go to the request page
}
Else
Result. Text = "Incorrect password ";
}
Else
Result. Text = "the user does not exist ";
Conn. Close ();
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.