All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET中散列加密密码_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/8 7:01:57 Browse times: 395 Comment times: 0

ASP.NET中散列加密密码_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET中散列加密密码_[Asp.Net教程]

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.AppSettings["connectionString"]);
SqlDataReader myreader=new SqlCommand(sql,conn).ExecuteReader();
if(myreader.Read())
{
String hashed=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordTextBox.Text,"SHA1");
//将用户输入的密码哈希后再与数据库是的哈希值进行比较
if(hash==myreader["password"]).ToString())
{
FormsAuthentication.RedirectFromLoginPage(UseridBox.Text,true);//转到请求页
}
else
Result.Text="密码错误";
}
else
Result.Text="用户不存在";
conn.Close();
}

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.