PHP 生成独一的激活码

WBOY
發布: 2016-06-13 11:58:26
原創
1453 人瀏覽過

PHP 生成唯一的激活码

<?php /** * 生成永远唯一的激活码 * @return string */function create_guid($namespace = null) {	static $guid = &#39;&#39;;	$uid = uniqid ( "", true );		$data = $namespace;	$data .= $_SERVER [&#39;REQUEST_TIME&#39;]; 	// 请求那一刻的时间戳	$data .= $_SERVER [&#39;HTTP_USER_AGENT&#39;]; 	// 获取访问者在用什么操作系统	$data .= $_SERVER [&#39;SERVER_ADDR&#39;]; 		// 服务器IP	$data .= $_SERVER [&#39;SERVER_PORT&#39;]; 		// 端口号	$data .= $_SERVER [&#39;REMOTE_ADDR&#39;]; 		// 远程IP	$data .= $_SERVER [&#39;REMOTE_PORT&#39;]; 		// 端口信息		$hash = strtoupper ( hash ( &#39;ripemd128&#39;, $uid . $guid . md5 ( $data ) ) );	$guid = &#39;{&#39; . substr ( $hash, 0, 8 ) . &#39;-&#39; . substr ( $hash, 8, 4 ) . &#39;-&#39; . substr ( $hash, 12, 4 ) . &#39;-&#39; . substr ( $hash, 16, 4 ) . &#39;-&#39; . substr ( $hash, 20, 12 ) . &#39;}&#39;;		return $guid;}//使用echo $key = create_guid ();
登入後複製

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!