title: MD5 Hashing between VB.net and PHP
body: <p><strong>Answered with the help of @JonSkeet</strong></p>
  
  <p>Given this code:</p>
  
  <pre><code>    Dim data1ToHash As Byte() = (New UnicodeEncoding).GetBytes(input)
      ' 2. Hash the byte array
      Dim hashvalue1 As Byte() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(data1ToHash)
  </code></pre>
  
  <p>Shouldn't this PHP produce the correct hash?</p>
  
  <p><code>$md5 = (md5(utf8_encode($signature), true));</code></p>
  
  <p>I tried, but the md5sums aren't matching up. I assumed it was encoding, but perhaps it has to do with the byte array, can anyone shed some light on this? FYI I can't change the VB</p>
  
  <p>To compare the results:</p>
  
  <p>in .Net</p>
  
  <pre><code>For Each b As Byte In hashvalue1
    tb.Text = tb.Text &amp; b.ToString() &amp; ","
  Next
  tb.Text = tb.Text.Trim(",")
  </code></pre>
  
  <p>in PHP</p>
  
  <p><code>print_r(unpack('C*', pack('H*', md5($signature))))</code></p>
  
  <p>as per another question</p>