English (English) - Change language

ValidateUser

What it does

Checks whether a user name and a password match the values in the database.

Definition

bool ValidateUser( string userName, string passwordHash );
    

Parameters

Name Type Description
userName string User name
passwordHash string Password hash

Sample code for calculating the password hash:

public static string GetPasswordHashWithSalt( string login, string password )
        {
            string salt = GetPasswordSha256Hash(login.ToUpper());
            return GetPasswordSha256Hash(password + salt);
        }
        private static string GetPasswordSha256Hash( string password )
        {
            Encoding enc = Encoding.GetEncoding("UTF-16");
            byte[] buffer = enc.GetBytes(password);
            var cryptoTransformSHA256 = new SHA256CryptoServiceProvider();
            string hash = BitConverter.ToString(cryptoTransformSHA256.ComputeHash(buffer)).Replace("-", "");
            return hash;
        }
    
    

Returned value

Type Description
bool
  • "true" if values match
  • otherwise "false" is returned

15.09.2020 9:42:43


Please leave your feedback about this article