一个登录程序
将用户名和密码放在了web.config中,其中密码以SHA1加密,为什么通不过验证?
<forms name=".COOKIEDEMO" loginUrl="login.aspx" protection="All" timeout="60" path="/">
<credentials passwordFormat="SHA1">
<user name="LemongTree" password="F749D95DC90B930F80FC2AFCED6C5D205103DB8E" />
</credentials>
</forms>
-------------------
private bool chkadmin(string username,string password)
{
string strpassword=FormsAuthentication.HashPasswordForStoringInConfigFile(password,"SHA1");
this.pwd=strpassword;
if(FormsAuthentication.Authenticate(username,strpassword))
{ return true;
}
else
{
return false;
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string username=this.TextBox1.Text;
string pwd=this.TextBox2.Text;
string www=FormsAuthentication.HashPasswordForStoringInConfigFile(pwd,"SHA1");
Response.Write(www);
if (chkadmin(username,pwd))
{
FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text, this.CheckBox1.Checked);
}
else
{
Response.Write("错误的用户名或密码");
} }
输入正确的密码还是提示错误,什么原因?另外:ASP.Net中的MD5加密与现在ASP中常用的MD5加密算法是不是一样?
将用户名和密码放在了web.config中,其中密码以SHA1加密,为什么通不过验证?
<forms name=".COOKIEDEMO" loginUrl="login.aspx" protection="All" timeout="60" path="/">
<credentials passwordFormat="SHA1">
<user name="LemongTree" password="F749D95DC90B930F80FC2AFCED6C5D205103DB8E" />
</credentials>
</forms>
-------------------
private bool chkadmin(string username,string password)
{
string strpassword=FormsAuthentication.HashPasswordForStoringInConfigFile(password,"SHA1");
this.pwd=strpassword;
if(FormsAuthentication.Authenticate(username,strpassword))
{ return true;
}
else
{
return false;
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string username=this.TextBox1.Text;
string pwd=this.TextBox2.Text;
string www=FormsAuthentication.HashPasswordForStoringInConfigFile(pwd,"SHA1");
Response.Write(www);
if (chkadmin(username,pwd))
{
FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text, this.CheckBox1.Checked);
}
else
{
Response.Write("错误的用户名或密码");
} }
输入正确的密码还是提示错误,什么原因?另外:ASP.Net中的MD5加密与现在ASP中常用的MD5加密算法是不是一样?
解决方案 »
- nhibernate 在 web.config 中如何配置
- 获取表中数据 求帮助 在线等待
- Fckeditor 在asp.net里的配置使用?点击“插入编辑图像”,再点击“浏览服务器端”,弹出窗口“xml request error:........”"Requested url............ "错误,怎么回事?哪里处理问题?
- 一个郁闷的问题
- 金贸通网站客服软件发布(www.kingtalk.cn),抢注靓号,免费使用
- 请问我的系统为什么不能运行ASP。NET程序啊
- 文件上传的控件在那里找?
- 有什么控件是可以跨帧的
- 如果让各项目共同引用一个WEB用户控件
- .net系统出现问题,请高手助阵!谢谢
- 大家讨论一下中国人校友录中班级相册中的图片显示和分页是怎么实现的,我想实现相同的功能,但有难度
- 下面这句话错哪了?
ASP中一般是16位的。