码迷,mamicode.com
首页 > 其他好文 > 详细

生成随机邀请码

时间:2018-11-05 11:09:08      阅读:391      评论:0      收藏:0      [点我收藏+]

标签:func   bcd   time()   ++   make   sprint   turn   nop   code   

function makecode(){

    $code="ABCDEFGHIGKLMNOPQRSTUVWXYZ";

    $rand=$code[rand(0,25)].strtoupper(dechex(date(‘m‘)))

        .date(‘d‘).substr(time(),-5)

        .substr(microtime(),2,5).sprintf(‘%02d‘,rand(0,99));

    for(

        $a = md5( $rand, true ),

        $s = ‘0123456789ABCDEFGHIJKLMNOPQRSTUV‘,

        $d = ‘‘,

        $f = 0;

        $f < 6;

        $g = ord( $a[ $f ] ), // ord()函数获取首字母的 的 ASCII值

        $d .= $s[ ( $g ^ ord( $a[ $f + 8 ] ) ) - $g & 0x1F ],  //按位亦或,按位与。

        $f++

    );

    return $d;

}

 

生成随机邀请码

标签:func   bcd   time()   ++   make   sprint   turn   nop   code   

原文地址:https://www.cnblogs.com/chengfengchi/p/9907710.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!