PHP 生成独一的激活码

WBOY
Release: 2016-06-13 11:58:26
Original
1451 people have browsed it

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 ();
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!