码迷,mamicode.com
首页 > Web开发 > 详细

PHP 生成唯一的激活码

时间:2017-04-26 16:40:26      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:div   生成   pre   ash   ring   操作系统   激活码   guid   gui   

<?

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 ();


PHP 生成唯一的激活码

标签:div   生成   pre   ash   ring   操作系统   激活码   guid   gui   

原文地址:http://www.cnblogs.com/slgkaifa/p/6769034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!