麻烦高手帮我解决下这个问题 关于MD5的问题
本帖最后由 imiles 于 2013-03-30 12:19:00 编辑
我是个新手,MD5功能已经实现,但是登陆的时候,无法进行密码转换,我把代码展示出来,请各位高手帮我看看!
这个是login.aspx.cs的页面
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
if (Response.Cookies["PrevUser"] != null)
TextBoxUser.Text = Response.Cookies["PrevUser"].Value;
}
protected void ButtonLogin_Click(object sender, EventArgs e)
{
if(CheckBoxRember.Checked==true)
{
Response.Cookies["PrevUser"].Value=TextBoxUser.Text;
Response.Cookies["PrevUser"].Expires = DateTime.Now.AddDays(7);
}
string checkCode = Session["CheckCode"].ToString();
if (TextBoxCheckCode.Text != checkCode)
{
Response.Write("<script>alert('验证码输入错误!')</script>");
return;
}
SqlConnection con = new SqlConnection("server=(local);database=DaRen;uid=sa;pwd=123;");
con.Open();
string userName, userPass;
userName = TextBoxUser.Text.Replace("'", "''");
userPass = TextBoxPassword.Text.Replace("'", "''");
String sqlStr = "select count(*) from [user] where userName='" + userName
+ "'and userPass='" + userPass + "'";
SqlCommand com = new SqlCommand(sqlStr, con);
com.Parameters.AddWithValue("@name", TextBoxUser.Text);
com.Parameters.AddWithValue("@pass", FormsAuthentication.HashPasswordForStoringInConfigFile(TextBoxPassword.Text, "MD5"));
int result=(int)com.ExecuteScalar();
&nbs