标题:哪位大神能帮我把MD5加密的登陆模式换成普通的登陆模式
只看楼主
kick10530
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-6-9
结帖率:100%
已结贴  问题点数:10 回复次数:3 
哪位大神能帮我把MD5加密的登陆模式换成普通的登陆模式
    protected void Button1_Click(object sender, EventArgs e)
    {
     String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");  
        SqlStr = "select * from 管理员表 where 用户名='" + this.txt_User_Name.Text + "' and 密码='" + Md5_User_Pwd + "'";
        Ds = db.GetDataTableBySql(SqlStr);
        try
        {
            if (Ds.Tables[0].Rows.Count == 0)
            {
                this.Labinfo.Text = "用户名或密码错误,请重试!";
                this.txt_User_Name.Focus();
            }
            else
            {
               this.Labinfo.Text = "管理员  " + this.txt_User_Name.Text + "  恭喜您登录成功!";
               Session["Admin_UserName"] = this.txt_User_Name.Text;
            }
        }
        catch (Exception)
        {
            this.Labinfo.Text = "没有得到任何数据,请重试!";
        }
    }
搜索更多相关主题的帖子: MD5加密 用户名 管理员 where 密码 
2013-07-02 11:27
party620
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:18
帖 子:696
专家分:2521
注 册:2013-1-31
得分:10 
如何你数据库存的是加密后的密码,你再登陆时把加密给去了,你就等不上了
2013-07-02 11:43
kick10530
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-6-9
得分:0 
这个是我完整的代码,管理的那里我不知道设计,我在数据库设计的密码为123456,不过我知道加密后就不是123456,;可我不知道怎么设计加密密码,
public partial class login_usercontrol : System.Web.UI.UserControl
{
    String SqlStr;
    DB db = new DB();
    DataSet Ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");
        SqlStr = "select * from 会员表 where 会员名='" + this.txt_User_Name.Text + "' and 密码='" + Md5_User_Pwd + "'";
        Ds = db.GetDataTableBySql(SqlStr);
        try
        {
            if (Ds.Tables[0].Rows.Count == 0)
            {
                this.Labinfo.Text = "用户名或密码错误,请重试!";
                this.txt_User_Name.Focus();
            }
            else
            {
                this.Labinfo.Text = "用户  " + this.txt_User_Name.Text + "  恭喜您登录成功!";
                Session["UserName"] = this.txt_User_Name.Text;
            }
        }
        catch (Exception)
        {
            this.Labinfo.Text = "没有得到任何数据,请重试!";
        }
    }
    protected void btn_Register_Click(object sender, EventArgs e)
    {
        Response.Redirect("zhuce.aspx");
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
     String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");  
        SqlStr = "select * from 管理员表 where 用户名='" + this.txt_User_Name.Text + "' and 密码='" + Md5_User_Pwd + "'";
        Ds = db.GetDataTableBySql(SqlStr);
        try
        {
            if (Ds.Tables[0].Rows.Count == 0)
            {
                this.Labinfo.Text = "用户名或密码错误,请重试!";
                this.txt_User_Name.Focus();
            }
            else
            {
               this.Labinfo.Text = "管理员  " + this.txt_User_Name.Text + "  恭喜您登录成功!";
               Session["Admin_UserName"] = this.txt_User_Name.Text;
            }
        }
        catch (Exception)
        {
            this.Labinfo.Text = "没有得到任何数据,请重试!";
        }
    }
}
2013-07-02 14:51
party620
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:18
帖 子:696
专家分:2521
注 册:2013-1-31
得分:0 
如果你设计的数据后台不是加密的,你把
String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");  
换为:String Md5_User_Pwd =this.txt_User_Pwd.Text.ToString();即可

如果你想设计的数据库是加密的,你需要在注册代码中把密码文本框加密:String Md5_User_Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_User_Pwd.Text.ToString(), "MD5");这样你的登陆就不用动啦
2013-07-02 15:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-416500-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.168280 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved