zoukankan      html  css  js  c++  java
  • ASP.NET自带的散列加密口令【转】

    使用ASP.NET自带类FormsAuthentication实现散列加密口令。
    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();
    }
  • 相关阅读:
    Java 老兵不死,Kotlin 蓄势待发
    程序员写代码时戴着耳机,在听什么?
    推荐 7 个提升前端编程效率的 VSCode 插件
    去掉烦人的 !=null
    透析!软件开发未来 10 年的 8 个趋势
    10月01日总结
    09月29日总结
    09月28日总结
    09月27日总结
    09月26日总结
  • 原文地址:https://www.cnblogs.com/myssh/p/1493190.html
Copyright © 2011-2022 走看看