Q: Login with hashed password asp mvc I am creating a simple application, i have created the hash for the password at register, but can not apply the hash at login. Currently i can not login with new users who have hashed passwords. Any help would be much appreciated. Currently i have: (Register)
    public String HashPassword(String password)
    {
        var combinedPassword = String.Concat(password);
        var sha256 = new SHA256Managed();
        var bytes = UTF8Encoding.UTF8.GetBytes(combinedPassword);
        var hash = sha256.ComputeHash(bytes);
        return Convert.ToBase64String(hash);
    }

    public void AddUserAccount(UserSignUpView user)
    {

        using (DemoDBEntities db = new DemoDBEntities())
        {

            SYSUser SU = new SYSUser();
            SU.PasswordEncryptedText = HashPassword(user.Password);
            SU.LoginName = user.LoginName;

            SU.RowCreatedSYSUserID = user.SYSUserID > 0 ? 

            user.SYSUserID : 1;
            SU.RowModifiedSYSUserID = user.SYSUserID > 0 ? 

            user.SYSUserID : 1; ;
            SU.RowCreatedDateTime = DateTime.Now;
            SU.RowMOdifiedDateTime = DateTime.Now;



            db.SYSUsers.Add(SU);
            db.SaveChanges();

This all works fine to register and hash. This is what i have for login:
public Boolean ValidatePassword(String enteredPassword, String storedHash)
    {
        var hasher = HashPassword(enteredPassword);
        return String.Equals(storedHash, hasher);
    }
    public string GetUserPassword(string enteredPassword)
    {
        using (DemoDBEntities db = new DemoDBEntities())
        {
            var hash = HashPassword(enteredPassword);
            var user = db.SYSUsers.Where(o => 
            o.PasswordEncryptedText.Equals(enteredPassword));
            if (user.Any())
                return user.FirstOrDefault().PasswordEncryptedText;
            else
                return string.Empty;
        }
    }

In the controller i have:
    public ActionResult LogIn(UserLoginView ULV, string returnUrl)

    {
        if (ModelState.IsValid)
        {

            UserManager UM = new UserManager();
            string password = UM.GetUserName(ULV.LoginName);
            string hash = UM.GetUserPassword(ULV.Password);
            //var password = ComputeHash(password, new SHA256CryptoServiceProvider());



            if (string.IsNullOrEmpty(hash))
                ModelState.AddModelError("", "The user  login or password provided is incorrect.");
            else {
                if (ULV.Password.Equals(hash)&&(ULV.LoginName.Equals(password)))
                {
                    FormsAuthentication.SetAuthCookie(ULV.LoginName, false);
                    return RedirectToAction("Welcome", "Home");
                }
                else {
                    ModelState.AddModelError("", "The password provided is incorrect.");
                }
            }
        }


A: It looks like you are getting the hashed password from the database with the line string hash = UM.GetUserPassword(ULV.Password); and then comparing it to the value that was entered with this line ULV.Password.Equals(hash).  Since one is hashed and the other is not, they will never be equal.

A: This worked:
            string password = UM.GetUserName(ULV.LoginName);
            string hash = UM.GetUserPassword(ULV.Password);
            string hashit = HashPassword(ULV.Password);

          public string GetUserPassword(string enteredPassword)
    {
        using (DemoDBEntities db = new DemoDBEntities())
        {
            var hash = HashPassword(enteredPassword);
            var user = db.SYSUsers.Where(o => o.PasswordEncryptedText.Equals(hash));
            if (user.Any())
                return user.FirstOrDefault().PasswordEncryptedText;
            else
                return string.Empty;
        }
    }

