メインコンテンツへスキップ

機能

ユーザー名とパスワードがデータベース内の値と一致するかどうかを確認します。

定義

bool ValidateUser( string userName, string passwordHash );

パラメーター

Name説明
userNamestringユーザー名
passwordHashstringパスワード ハッシュ
パスワード ハッシュを計算するコード例:
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;
        }

戻り値

説明

bool

  • 値が一致する場合は “true”
  • それ以外の場合は “false”