示例#1
0
 public Player(string username, string password, string passwordSalt = null, bool hashProvided = false)
 {
     _username = username;
     if (!hashProvided)
     {
         if (passwordSalt != null)
         {
             _passwordSalt = passwordSalt;
         }
         else
         {
             _passwordSalt = PasswordHashing.CreateSalt(8);
         }
         _passwordHash = PasswordHashing.CreatePasswordHash(password, _passwordSalt);
     }
     else
     {
         _passwordSalt = passwordSalt;
         _passwordHash = password;
     }
 }
示例#2
0
        public bool CheckPassword(string password)
        {
            string newPassHash = PasswordHashing.CreatePasswordHash(password, _passwordSalt);

            return(_passwordHash == newPassHash);
        }