note 68781 added to function.hash-hmac
| From: | jason at techadept dot com | Date: | Thu, 10 Aug 2006 16:47:00 +0000 |
| Subject: | note 68781 added to function.hash-hmac | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115764@lists.php.net to get a copy of this message | ||
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))));
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 24.1.180.62
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.hash-hmac.php
Edit -- https://master.php.net/note/edit/68781
Del: integrated -- https://master.php.net/note/delete/68781/integrated
Del: useless -- https://master.php.net/note/delete/68781/useless
Del: bad code -- https://master.php.net/note/delete/68781/bad+code
Del: spam -- https://master.php.net/note/delete/68781/spam
Del: non-english -- https://master.php.net/note/delete/68781/non-english
Del: in docs -- https://master.php.net/note/delete/68781/in+docs
Del: other reasons-- https://master.php.net/note/delete/68781
Reject -- https://master.php.net/note/reject/68781
Search -- https://master.php.net/manage/user-notes.php