WaveBox.Core.Model.User.Authenticate C# (CSharp) Method

Authenticate() public method

public Authenticate ( string password ) : bool
password string
return bool
        public bool Authenticate(string password)
        {
            // Compute hash
            string hash = ComputePasswordHash(password, this.PasswordSalt);

            // Ensure hashes are same length
            if (hash.Length != this.PasswordHash.Length)
            {
                return false;
            }

            // Compare ASCII value of each character, bitwise OR any diff
            int status = 0;
            for (int i = 0; i < hash.Length; i++)
            {
                status |= ((int)hash[i] ^ (int)this.PasswordHash[i]);
            }

            return status == 0;
        }