一级a做爰片阿v祥仔网站,公司注册网上申请网站,网站建设的目的与意义是什么,icoc.cc是哪个网站域名最近研究网宿云文档API#xff0c;其中用到了一种叫hmac_sha1的签名算法#xff1b; HMAC-SHA1#xff1a; HMAC是哈希运算消息认证码 (Hash-based Message Authentication Code)#xff0c;HMAC运算利用哈希算法#xff0c;以一个密钥和一个消息为输入#xff0c;生成一…最近研究网宿云文档API其中用到了一种叫hmac_sha1的签名算法 HMAC-SHA1 HMAC是哈希运算消息认证码 (Hash-based Message Authentication Code)HMAC运算利用哈希算法以一个密钥和一个消息为输入生成一个消息摘要作为输出。HMAC-SHA1签名算法是一种常用的签名算法用于对一段信息进行生成签名摘要。 PHP代码实现 /*** 获取hmac_sha1签名的值* link 代码来自 http://www.educity.cn/develop/406138.html** param $str 源串* param $key 密钥** return 签名值*/function hmac_sha1($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) amp;gt; $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;}
} 注自PHP5.1.2起就已经内置了hash_hmac函数所以可不必做function_exsits的判断一行代码便可获取hmac_sha1签名值 $signature base64_encode(hash_hmac(sha1, $str, $key, true)); 转载于:https://www.cnblogs.com/AllenChou/p/7651306.html