title: Match C# MD5 hashing algorithm with node.js
body: <p>I am having trouble matching a C# hashing algorithm with node, the problem seems to be the Unicode encoding. Is there a way to convert a string to Unicode then hash it and output it as hexadecimal? Unfortunately I cannot change the c# code, it is out of my control.</p>
  
  <p>node algorithm</p>
  
  <pre><code>function createMd5(message) {
      var crypto = require("crypto");
      var md5 = crypto.createHash("md5");        
      return md5.update(message).digest('hex');
  }
  </code></pre>
  
  <p>c# hashing algorithm</p>
  
  <pre><code> private static string GetMD5(string text)
      {
          UnicodeEncoding UE = new UnicodeEncoding();
          byte[] hashValue;
          byte[] message = UE.GetBytes(text);
          using (MD5 hasher = new MD5CryptoServiceProvider())
          {
              string hex = "";
              hashValue = hasher.ComputeHash(message);
              foreach (byte x in hashValue)
              {
                  hex += String.Format("{0:x2}", x);
              }
  
              return hex.ToLower();
  
          }
      }
  </code></pre>