Here's my code. Again, don't laugh... This is the first function I've ever attempted to write.
Code: Select all
<?
function hmac_md5($key, $data)
{
$l = '16';
$b = '64';
if (strlen($key) > $b)
$key = md5($key);
while (strlen($key) < $b)
{
$key = $key."0";
//echo $key;
//echo "<br>";
//echo strlen($key)."<br>";
}
for ($i='0'; $i<='64'; $i++)
{
//echo $i."<br>";
$ipad = $ipad.chr(0x36);
$opad = $opad.chr(0x36);
//echo $ipad."<br>";
//echo $opad."<br>";
//echo "<br>";
}
$ipad = $key ^ $ipad;
$opad = $key ^ $opad;
//echo $ipad."<br>";
//echo $opad."<br>";
$result = md5($opad.(md5($ipad.$data)));
echo $result;
}
?>