PHP 生成唯一的激活碼


<?

php /** * 生成永遠唯一的激活碼 * @return string */ function create_guid($namespace = null) { static $guid = ''; $uid = uniqid ( "", true ); $data = $namespace; $data .= $_SERVER ['REQUEST_TIME']; // 請求那一刻的時間戳 $data .= $_SERVER ['HTTP_USER_AGENT']; // 獲取訪問者在用什么操作系統 $data .= $_SERVER ['SERVER_ADDR']; // serverIP $data .= $_SERVER ['SERVER_PORT']; // port號 $data .= $_SERVER ['REMOTE_ADDR']; // 遠程IP $data .= $_SERVER ['REMOTE_PORT']; // port信息 $hash = strtoupper ( hash ( 'ripemd128', $uid . $guid . md5 ( $data ) ) ); $guid = '{' . substr ( $hash, 0, 8 ) . '-' . substr ( $hash, 8, 4 ) . '-' . substr ( $hash, 12, 4 ) . '-' . substr ( $hash, 16, 4 ) . '-' . substr ( $hash, 20, 12 ) . '}'; return $guid; } //使用 echo $key = create_guid ();



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM