title: HMAC-MD5 signature - translate key from hex to byte format php
body: <p>I need to digitally sign some post data using HMAC-MD5 algo.</p>
  
  <p>I have the key and a sample string (to which I know what the hex sign should be.</p>
  
  <p>My problem is when I use the hash_hmac php function the key it generates is different to what it should be.</p>
  
  <p>The instructions are:</p>
  
  <ol>
  <li><p>translate HMAC key from hex to byte format - <em>not sure how to do that</em></p></li>
  <li><p>sign the string using HMAC-MD5 procedure based on merchant’s HMAC
  key - <em>this bit is fine</em></p></li>
  <li><p>translate signature from byte to hex format and associate it as
  value with parameter sign - <em>not sure what to do here either</em></p></li>
  </ol>
  
  <p>I've tried using this for step 1) $key2 = pack("H*" , $key)
  and this for step 2) bin2hex ( $sign ) which don't work as hoped.</p>
  
  <p>The only online HMAC-MD5 generator that I've found that produced the correct sign is here: 
  <a href="http://membres.multimania.fr/brudav/hash.php" rel="nofollow">http://membres.multimania.fr/brudav/hash.php</a> when 'hexa' is selected. I obviously don't know how this works it out though.</p>
  
  <p>Can anyone offer me any advise?</p>