Ok. I know I can use the mhash() function, but my service provider doesn't have it enabled. I'm attempting to write an HMAC function for MD5. I have a good understanding of the process, but seeing as I'm a coding newb there are a couple things that are stumping me. If you need more info on what HMAC is here ya go. http://www.faqs.org/rfcs/rfc2104.html
Here's my code. Again, don't laugh... This is the first function I've ever attempted to write. PHP:------------------------------------------------------------------------ ------ <? 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.'0x36'; $opad = $opad.'0x5c'; //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; } ?> ---------------------------------------------------------------------------- -- Ignore the echo statements. I was trying to use those to help me test. Anyway. I'm sure where I'm messing up is the values for opad and ipad. If someone could help me clear those up, I would greatly appreciate it. Thanks a ton. Oh yeah, I had orginally intended to add a $hash variable to the function so you could specify the hash type. That way it will work with the different hash types that the mhash() function supports. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php