登錄MD5加密
/// <summary>
/// 登錄方法
/// </summary>
/// <param name="Name"></param>
/// <param name="Pwd"></param>
/// <returns></returns>
public int LoginDo(string Name, string Pwd)
{
string MD5pwd = Md5Hash(Pwd);
Session["name"] = Name;
var userId = userinfoBLL.Login(Name, MD5pwd);
Session["UserId"] = userId;
Session["Id"] = userId;
return userId;
}
/// <summary>
/// 輸入原密碼返回加密後的密文
/// </summary>
/// <param name="input">輸入的密碼</param>
/// <returns></returns>
private string Md5Hash(string input)
{
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
/// <summary>
/// 添加用戶方法
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public int AddUserInfoDo(UserInfo_Model userInfo)
{
userInfo.PassWord = Md5Hash(userInfo.PassWord);
return userinfoBLL.AddUserInfo(userInfo);
}
登錄MD5加密