title: .NET md5 doesn't equal md5sum.exe on unix
body: <p>So I have an issue with comparing MD5 sums of the same text using the same techniques. I am using .NET MD5 tools and Unix's md5sum.exe program.</p>
  
  <p>Here's my .NET code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void Test()
  {
      string str1 = "testline1";
      string str2 = "testline2";
      StringBuilder sb = new StringBuilder();
  
      sb.Append(str1);
      sb.Append(Constants.vbLf);
      sb.Append(str2);
  
      string hash = GetMD5Hash(sb.ToString());
  
      //hash = 4fb435ffb8e071151c3411dd3a922460
  }
  
  public string GetMD5Hash(string text)
  {
      byte[] hash;
      using (MD5 md5 = MD5.Create())
      {
          hash = md5.ComputeHash(Encoding.UTF8.GetBytes(text));
      }
  
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i &lt; hash.Length; i++)
      {
          sb.Append(hash[i].ToString("x2"));
      }
  
      return sb.ToString();
  }
  </code></pre>
  
  <p>I have a server running a unix based OS which has md5sum.exe on it. On my server I have a file which is simply:</p>
  
  <pre><code>testline1
  testline2
  </code></pre>
  
  <p>Let's say the file is named testFile.txt</p>
  
  <p>I have tried running multiple variations of md5sum to see if I can get these values to equal to no avail.</p>
  
  <pre><code>$md5sum testFile.txt                     //22f877bcf8985a0f038a5b70086b955d
  $echo -n $(cat testFile.txt) | md5sum    //1e192bb9877cc2f20e7010d499c0a306
  $echo -E $(cat testFile.txt) | md5sum    //83b6873b79ca36952eb58ea05083c02e
  
  $unix2dos testFile.txt  //converting file to dos just in case line endings are issue
  $md5sum testFile.txt                     //d302436fa25c7faaab75ceca1f1df16d
  $echo -n $(cat testFile.txt) | md5sum    //94f0c8f7e9820cb6eda9e911ee21b2a8
  $echo -E $(cat testFile.txt) | md5sum    //f39452a70621ed225057073e86f17858
  </code></pre>
  
  <p>I have worked at this for hours and cannot seem to get these MD5 to match. Any ideas?</p>