New secure cookie protocol. see #5367

git-svn-id: https://develop.svn.wordpress.org/trunk@6387 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2007-12-16 17:41:59 +00:00
parent 3155e09967
commit bb7922cd42
7 changed files with 171 additions and 116 deletions

View File

@@ -147,6 +147,27 @@ if (!function_exists('stripos')) {
}
}
if ( ! function_exists('hash_hmac') ):
function hash_hmac($algo, $data, $key, $raw_output = false) {
$packs = array('md5' => 'H32', 'sha1' => 'H40');
if ( !isset($packs[$algo]) )
return false;
$pack = $packs[$algo];
if (strlen($key) > 64)
$key = pack($pack, $algo($key));
else if (strlen($key) < 64)
$key = str_pad($key, 64, chr(0));
$ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
$opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
return $algo($opad . pack($pack, $algo($ipad . $data)));
}
endif;
// Added in PHP 4.3.0?
if (!defined('IMAGETYPE_GIF'))
define('IMAGETYPE_GIF', 1);