Encryption algorithm:
Using the HMAC-SHA1 signature method
Copy CodeThe code is as follows:
/**
* @brief generate Oauth_signature signature values using the HMAC-SHA1 algorithm
*
* @param $key Key
* @param $str Source string
*
* @return Signature Value
*/
function Getsignature ($STR, $key) {
$signature = "";
if (function_exists (' Hash_hmac ')) {
$signature = Base64_encode (Hash_hmac ("SHA1", $str, $key, true));
} else {
$blocksize = 64;
$hashfunc = ' SHA1 ';
if (strlen ($key) > $blocksize) {
$key = Pack (' h* ', $hashfunc ($key));
}
$key = Str_pad ($key, $blocksize, Chr (0x00));
$ipad = Str_repeat (Chr (0x36), $blocksize);
$opad = Str_repeat (Chr (0x5c), $blocksize);
$hmac = Pack (
' h* ', $hashfunc (
($key ^ $opad). Pack
' h* ', $hashfunc (
($key ^ $ipad). $str
)
)
)
);
$signature = Base64_encode ($HMAC);
}
return $signature;
}
http://www.bkjia.com/PHPjc/327907.html www.bkjia.com true http://www.bkjia.com/PHPjc/327907.html techarticle encryption algorithm: Use the HMAC-SHA1 signature method to copy the code code as follows:/** * @brief generate oauth_signature Signature value using HMAC-SHA1 algorithm * * @param $key key * @param $str source string. .