note 68781 deleted from function.hash-hmac by nlopess

From: Date: Mon, 14 Aug 2006 23:22:10 +0000
Subject: note 68781 deleted from function.hash-hmac by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115918@lists.php.net to get a copy of this message
Note Submitter: jason at techadept dot com ---- This function is a slightly modified version of eddi's code here from 2006-05-10. When I used it, it was capable of making Authorize.net's simlib.php work without mhash. I've posted some comments about it at http://www.mosaek.com . <? function hmac($passwd, $data) { $algo = "md5"; /* md5 and sha1 only */ $algo=strtolower($algo); $p=array('md5'=>'H32','sha1'=>'H40'); if(strlen($passwd)>64) $passwd=pack($p[$algo],$algo($passwd)); if(strlen($passwd)<64) $passwd=str_pad($passwd,64,chr(0)); $ipad=substr($passwd,0,64) ^ str_repeat(chr(0x36),64); $opad=substr($passwd,0,64) ^ str_repeat(chr(0x5C),64); return($algo($opad.pack($p[$algo],$algo($ipad.$data)))); } ?>

« previous php.notes (#115918) next »