登录会员中心设置或获取API key,这里我们做以下假设:
e1TZWs5SLtm8CFZ3n9
需要以下信息
生成方法 (以PHP为例子)
<?php
/*
* @param $timeStamp 时间戳
* @param $randomStr 随机字符串
* @param $apiKey API key
* @return string 返回签名
*/
function arithmetic($timeStamp, $randomStr, $apiKey)
{
$arr['timeStamp'] = $timeStamp;
$arr['randomStr'] = $randomStr;
$arr['apiKey'] = $apiKey;
//按照首字母大小写顺序排序
sort($arr, SORT_STRING);
//拼接成字符串
$str = implode($arr);
//进行加密
$signature = md5($str);
//转换成大写
$signature = strtoupper($signature);
return $signature;
}
//随机生成字符串8位
function createNonceStr($length = 8)
{
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$str = "";
for ($i = 0; $i &amp;amp;lt; $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
$timeStamp = time(); //时间戳
$randomStr = createNonceStr(); //随机字符串
$apiKey = "e1TZWs5SLtm8CFZ3n9"; //API key
$signature = arithmetic($timeStamp, $randomStr, $apiKey);
echo $signature;
2DF9563499C4E9F8AB85A6FA2F963099
域网-领先的域名注册服务商
Copyright © 2005-2023 域网 版权所有
法律声明 | 隐私政策