如何在php中创建hmac md5?

I am working with payU credit card systems. But I dont manage. payU tells me that I have to create hmac md5 hashes.

My secret key is : 3~9#[X4^660?ak+]h6%T I want to convert to a HMAC_MD5 hash : 8GEMISEPE6208617192012-12-15 15:58:476Deneme117Deneme202103NET112242103TRY2107Antalya7Antalya2TR8CCVISAMC2,3,7,10,12

What's the php code?

You can easily do that using the hash_hmac() function:

$input = 'foo';
$output = hash_hmac('md5', $input, $secretKey);

where $secretKey holds a string representation of your key.

this php function class worked for me:

   function hmac ($key, $data)
              {
              // RFC 2104 HMAC implementation for php.
              // Creates an md5 HMAC.
              // Eliminates the need to install mhash to compute a HMAC
              // Hacked by Lance Rushing
              $b = 64; // byte length for md5
              if (strlen($key) > $b) {
              $key = pack("H*",md5($key));
              }
              $key = str_pad($key, $b, chr(0x00));
              $ipad = str_pad('', $b, chr(0x36));
              $opad = str_pad('', $b, chr(0x5c));
              $k_ipad = $key ^ $ipad ;
              $k_opad = $key ^ $opad;
              return md5($k_opad . pack("H*",md5($k_ipad . $data)));
              }


            $x_fp_hash = hmac($string1,$string2);