public Sysuser(string loginName, string password) { if (string.IsNullOrEmpty(loginName)) { throw new BaseException("登录名不能为空"); } if (string.IsNullOrEmpty(password) || password.Length < 6) { throw new BaseException("登录名密码不能少于6位"); } Salt = Guid.NewGuid().ToString(); LoginName = loginName; PasswordHash = PasswordStrategy.CreateWithMD5(password + Salt + _passwordStr); IsEnabled = true; }
/// <summary> /// 检查密码是否正确 /// </summary> /// <param name="password">密码</param> /// <returns></returns> public bool CheckPassword(string password) { return(PasswordStrategy.CreateWithMD5(password + Salt + _passwordStr) == PasswordHash); }