title: Encryption Comparing Hashed&Salted Password upon Login
body: <p>I have a simple password encrypter that gives me a hashed/salted password to store in my database when a user registers. Code: </p>
  
  <pre><code>public static string GenerateHashWithSalt(string enteredPassword, string enteredSalt)
      {
          string sHashWithSalt = enteredPassword + enteredSalt;
          byte[] saltedHashBytes = Encoding.UTF8.GetBytes(sHashWithSalt);
          System.Security.Cryptography.HashAlgorithm algorithm = new System.Security.Cryptography.SHA256Managed();
          byte[] hash = algorithm.ComputeHash(saltedHashBytes);
          return Convert.ToBase64String(hash);
      }
  </code></pre>
  
  <p>When a user logs in, I presume I can't simply put the entered password back through this code and compare as it would give me a different result. How can I <em>simply</em> compare the stored password against the entered log in password? </p>