library/core/class.cookieidentity.php
protected static function _HashHMAC($HashMethod, $Data, $Key) {
      $PackFormats = array('md5' => 'H32', 'sha1' => 'H40');

      if (!isset($PackFormats[$HashMethod]))
         return false;

      $PackFormat = $PackFormats[$HashMethod];
      // this is the equivalent of "strlen($Key) > 64":
      if (isset($Key[63]))
         $Key = pack($PackFormat, $HashMethod($Key));
      else
         $Key = str_pad($Key, 64, chr(0));

      $InnerPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x36), 64));
      $OuterPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x5C), 64));

      return $HashMethod($OuterPad . pack($PackFormat, $HashMethod($InnerPad . $Data)));
   }
protected static function _HashHMAC($HashMethod, $Data, $Key) {
      $PackFormats = array('md5' => 'H32', 'sha1' => 'H40');

      if (!isset($PackFormats[$HashMethod]))
         return false;

      $PackFormat = $PackFormats[$HashMethod];
      // this is the equivalent of "strlen($Key) > 64":
      if (isset($Key[63]))
         $Key = pack($PackFormat, $HashMethod($Key));
      else
         $Key = str_pad($Key, 64, chr(0));

      $InnerPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x36), 64));
      $OuterPad = (substr($Key, 0, 64) ^ str_repeat(chr(0x5C), 64));

      return $HashMethod($OuterPad . pack($PackFormat, $HashMethod($InnerPad . $Data)));
   }
protected static function _HashHMAC ( $ HashMethod , $ Data , $ Key ) { $ PackFormats = array ( 'md5' => 'H32' , 'sha1' => 'H40' ) ; if ( ! isset ( $ PackFormats [ $ HashMethod ] ) ) return false ; $ PackFormat = $ PackFormats [ $ HashMethod ] ; // this is the equivalent of "strlen($Key) > 64": if ( isset ( $ Key [ 63 ] ) ) $ Key = pack ( $ PackFormat , $ HashMethod ( $ Key ) ) ; else $ Key = str_pad ( $ Key , 64 , chr ( 0 ) ) ; $ InnerPad = ( substr ( $ Key , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ) ; $ OuterPad = ( substr ( $ Key , 0 , 64 ) ^ str_repeat ( chr ( 0x5C ) , 64 ) ) ; return $ HashMethod ( $ OuterPad . pack ( $ PackFormat , $ HashMethod ( $ InnerPad . $ Data ) ) ) ; }
Returns the provided data hashed with the specified method using the
specified key.

@param string $HashMethod The hashing method to use on $Data. Options are MD5 or SHA1.
@param string $Data The data to place in the hash.
@param string $Key The key to use when hashing the data.
Returns the provided data hashed with the specified method using the specified key .