//返回当前的毫秒时间戳
function msectime() {
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
return $msectime;
}
// 用timestamp+"\n"+AppSecret为签名字符串,AppSecret为签名密钥,使用算法HmacSHA256计算的签名值。
<?php
// 根据timestamp, appSecret计算签名值
$s = hash_hmac('sha256', 'timestamp', 'appSecret', true);
$signature = base64_encode($s);
var_dump($signature);
$urlencode_signature = urlencode($signature);
var_dump($urlencode_signature);
?>
本文来自博客园,作者:depressiom,转载请注明原文链接:https://www.cnblogs.com/depressiom/p/17240753.html