MD5 加密登录用户名称和密码
2016-12-13 11:48
211 查看
设 计过程
(1)新建一个ASP.NET 网站,将其命名为MD5,Web页默认名为Default.aspx,用于登录页面。
(2)在Default.aspx 中添加一个Table 表格、两个TextBox 控件及两个Button控件,分别用于布局Web页
面、输入用户名称和密码、执行登录和清空命令。
(3)主要程序代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string strName = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5");
string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5");
SqlConnection con = new SqlConnection("Server=(local);database=db_Tome2;Uid=sa;Pwd=");
SqlDataAdapter dap = new SqlDataAdapter("select * from 系统用户加密表 where username='" + strName + "'and pwd='" + strPwd + "'", con);
DataSet ds = new DataSet( );
dap.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Response.Write("<script>alert('登录成功!!!')</script>");
}
else
{
Response.Write("<script>alert('用户名或密码错误,登录失败!!!')</script>");
}
}
(1)新建一个ASP.NET 网站,将其命名为MD5,Web页默认名为Default.aspx,用于登录页面。
(2)在Default.aspx 中添加一个Table 表格、两个TextBox 控件及两个Button控件,分别用于布局Web页
面、输入用户名称和密码、执行登录和清空命令。
(3)主要程序代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string strName = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5");
string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5");
SqlConnection con = new SqlConnection("Server=(local);database=db_Tome2;Uid=sa;Pwd=");
SqlDataAdapter dap = new SqlDataAdapter("select * from 系统用户加密表 where username='" + strName + "'and pwd='" + strPwd + "'", con);
DataSet ds = new DataSet( );
dap.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Response.Write("<script>alert('登录成功!!!')</script>");
}
else
{
Response.Write("<script>alert('用户名或密码错误,登录失败!!!')</script>");
}
}
相关文章推荐
- java加密用户登录密码--不用MD5实现
- c# MD5 加密登录密码
- MD5 JAVA用户密码加密实现
- 单点登录之cas4.2.7服务端数据库配置(读数据库验证用户并对密码进行加密)
- JAVA用户注册登录使用MD5非对称加密解密
- 数据加密实战之记住密码、自动登录和加密保存数据运用DES和MD5混合使用
- MD5 单向加密,为保存用户密码
- C#:使用MD5对用户密码加密与解密
- java存储用户信息用MD5对密码加密
- 获取MySQL加密密码并验证用户输入(登录界面),retrieve hashpwd from mysql and compare with input password on login
- Cas单点登录(4)数据库验证用户之MD5密码加密
- (三)学习MVC之密码加密及用户登录
- 用户登录时的用户名密码加密解密问题和“记住密码”功能
- 用户名称 登录密码
- 用户登录对密码进行加密
- 用 MD5 加密数据库中的用户密码
- 用户登录增加密码RSA加密验证功能
- QuickCSharp框架开发(18)------加密用户名和密码数据与数据库读出的密码进行哈希比较(验证用户是否成功登录)
- 这才是一个完整的用户登录(Forms身份认证+记住密码+加密存储+LoginedPage/BasePage)
- 单点登录之cas4.2.7服务端数据库配置(读数据库验证用户并对密码进行加密)