title: Hash and salt passwords in C#
body: <p>I was just going through one of DavidHayden's articles on <a href="http://web.archive.org/web/20120413180026/http://davidhayden.com/blog/dave/archive/2004/02/16/157.aspx" rel="noreferrer">Hashing User Passwords</a>.</p>
  
  <p>Really I can't get what he is trying to achieve.</p>
  
  <p>Here is his code:</p>
  
  <pre><code>private static string CreateSalt(int size)
  {
      //Generate a cryptographic random number.
      RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
      byte[] buff = new byte[size];
      rng.GetBytes(buff);
  
      // Return a Base64 string representation of the random number.
      return Convert.ToBase64String(buff);
  }
  
  private static string CreatePasswordHash(string pwd, string salt)
  {
      string saltAndPwd = String.Concat(pwd, salt);
      string hashedPwd =
          FormsAuthentication.HashPasswordForStoringInConfigFile(
          saltAndPwd, "sha1");
      return hashedPwd;
  }
  </code></pre>
  
  <p>Is there any other C# method for hashing passwords and adding salt to it?</p>