zoukankan      html  css  js  c++  java
  • PHP 生成唯一激活码

    <?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']; 		// serverIP
    	$data .= $_SERVER ['SERVER_PORT']; 		// port号
    	$data .= $_SERVER ['REMOTE_ADDR']; 		// 远程IP
    	$data .= $_SERVER ['REMOTE_PORT']; 		// 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 ();

    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    学期总结
    C语言I博客作业09
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业06
    C语言I博客作业05
    C语言I博客作业04
    作业02
    c语言 学习笔记之二 选择题2
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4708166.html
Copyright © 2011-2022 走看看