title: Generate Unix-Style MD5 Password Hash in C#
body: <p>I am trying to generate a Unix-Style password hash using MD5. I undestand that I need it to look like <code>$1$&lt;salt&gt;$&lt;hash&gt;</code>, but the <code>&lt;hash&gt;</code> part does not look the same, no matter what I do. Here is how I generate the hash:</p>
  
  <pre><code>            MD5 md5 = System.Security.Cryptography.MD5.Create();
              byte[] inputBytes = System.Text.Encoding.UTF8.GetBytes(pass);
              byte[] hash = md5.ComputeHash(inputBytes);
  
              StringBuilder sb = new StringBuilder();
              for (int i = 0; i &lt; hash.Length; i++)
              {
                  sb.Append((char) hash[i]);
              }
  
              String calchash = sb.ToString();
  </code></pre>
  
  <p>I am pretty sure that it is now I am using the <code>StringBuilder</code> to make a string from the hashed bytes. But I don't know what the right settings would be.</p>