>  기사  >  백엔드 개발  >  PHP 生成唯一的激活码

PHP 生成唯一的激活码

WBOY
WBOY원래의
2016-06-23 13:56:043113검색

<?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']; 		// 服务器IP	$data .= $_SERVER ['SERVER_PORT']; 		// 端口号	$data .= $_SERVER ['REMOTE_ADDR']; 		// 远程IP	$data .= $_SERVER ['REMOTE_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 ();

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.