Make WordPress Core


Ignore:
Timestamp:
12/16/2007 05:41:59 PM (17 years ago)
Author:
ryan
Message:

New secure cookie protocol. see #5367

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/compat.php

    r6309 r6387  
    148148}
    149149
     150if ( ! function_exists('hash_hmac') ):
     151function hash_hmac($algo, $data, $key, $raw_output = false) {
     152    $packs = array('md5' => 'H32', 'sha1' => 'H40');
     153
     154    if ( !isset($packs[$algo]) )
     155        return false;
     156
     157    $pack = $packs[$algo];
     158
     159    if (strlen($key) > 64)
     160        $key = pack($pack, $algo($key));
     161    else if (strlen($key) < 64)
     162        $key = str_pad($key, 64, chr(0));
     163       
     164    $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
     165    $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
     166
     167    return $algo($opad . pack($pack, $algo($ipad . $data)));
     168}
     169endif;
     170
    150171// Added in PHP 4.3.0?
    151172if (!defined('IMAGETYPE_GIF'))
Note: See TracChangeset for help on using the changeset viewer.