note 65968 deleted from function.hash-hmac by pollita

From: Date: Wed, 13 Sep 2006 23:19:23 +0000
Subject: note 65968 deleted from function.hash-hmac by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117131@lists.php.net to get a copy of this message
Note Submitter: eddi at to-grip dot de ---- You can emulate it on older versions: <?php function hmac($algo,$data,$passwd){ /* 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)))); } ?> So it works fine for CRAM-MD5 and CRAM-SHA1 authentication.

« previous php.notes (#117131) next »