//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;