PHP生成唯一标识符token代码
//sha1()函数, "安全散列算法(SHA1)"
function create_unique() {
    //客户端+IP+时间戳+随机数组成的字符串
    $data = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'] .time() . rand();
    //使用sha1加密
    return sha1($data);
}
$newhash = create_unique();
echo "token方法1: ".$newhash."<br>";
$token = md5(uniqid(rand()));
echo "token方法2: ".$token;
                中国· 上海
 
                添加微信咨询
            CopyRight©2009-2019 上海谷谷网络科技有限公司 All Rights Reserved. 沪ICP备11022482号-8
- top
- 在线咨询
- 
            
             添加微信咨询 添加微信咨询
