生成GUID
// 生成guid
function guid() {
if (function_exists('com_create_guid')) {
return com_create_guid();
} else {
mt_srand((double) microtime() * 10000); //optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45); // "-"
$uuid = substr($charid, 0, 8) . $hyphen
. substr($charid, 8, 4) . $hyphen
. substr($charid, 12, 4) . $hyphen
. substr($charid, 16, 4) . $hyphen
. substr($charid, 20, 12);
return $uuid;
}
}
签名代码:
// 生成签名
function sign($data, $appKey) {
$arr = [];
foreach ($data as $key => $value) {
$arr[] = $key . '=' . $value;
}
$arr[] = 'key=' . $appKey;
$str = strtoupper(implode('&', $arr));
//$str = http_build_query($arr, '&');
// var_dump('签名前:'.$str);
// echo "<br />";
return strtoupper(md5($str));
}