ホームページ  >  記事  >  バックエンド開発  >  PHP 生成独一的激活码

PHP 生成独一的激活码

WBOY
WBOYオリジナル
2016-06-13 11:58:261451ブラウズ

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

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。