钢琴考级成绩分几档:.net中,用户登陆的密码如何校验,新增用户的密码是否有加密处理,如何加密?

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/03 22:52:03

md5加密方法:
public string md5(string str, int code)
{
if (code == 16) //16位MD5加密(取32位加密的9~25字符)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
if (code == 32) //32位加密
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
return null;
}

找到个加密的方法(网上有很多,很容易找到)
将用这个方法加密过的密码存入数据库
校验密码的时候,将用户输入的密码进行加密,然后与数据库中的密码比对,看是否一样(不要进行解密过程)

去下载个MD5加密函数

命名空间:
System.Web.Security
md5:
FormsAuthentication.HashPasswordForStoringInConfigFile("待加密字符", "MD5")