首页  >  文章  >  后端开发  >  获取唯一设备标识符

获取唯一设备标识符

WBOY
WBOY原创
2016-08-08 09:29:523508浏览

Cocos2dx下,包含头文件

std::string uid = "";
    uuid_t uu;
    int i;
    uuid_generate(uu);
    for (i = 0; i <br>php下(转)<p></p><pre code_snippet_id="599357" snippet_file_name="blog_20150206_2_8217663" name="code"><?php function create_guid(){
		$micortime = microtime();
		list($a_dec,$a_sec) = explode(" ", $micortime);
		$dec_hex = dechex($a_dec*1000000);
		$sec_hex = dechex($a_sec);
		ensure_length($dec_hex, 5);
		ensure_length($sec_hex, 6);
		$guid = "";
		$guid.=$dec_hex;
		$guid.=create_guid_section(3);
		$guid.=&#39;-&#39;;
		$guid.=create_guid_section(4);
		$guid.=&#39;-&#39;;
		$guid.=create_guid_section(4);
		$guid.=&#39;-&#39;;
		$guid.=create_guid_section(4);
		$guid.=&#39;-&#39;;
		$guid.=$sec_hex;
		$guid.=create_guid_section(6);
		return $guid;
	}
	
	function ensure_length(&$string,$length){
		$strlen = strlen($string);
		if ($strlen<$length) {
			$string = str_pad($string, $length,"0");
		}
		elseif ($strlen>$length){
			$string = substr($string, 0,$length);
		}
	}
	
	function create_guid_section($characters){
		$return = "";
		for ($i = 0;$i 

以上就介绍了获取唯一设备标识符,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn