生成固定长随机码

function R() {    
    $code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';    
    $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 < 8;        
        $g = ord( $a[ $f ] ),    
        $d .= $s[ ( $g ^ ord( $a[ $f + 8 ] ) ) - $g & 0x1F ],    
        $f++    
    );    
    return $d;    
}

 

posted @ 2018-02-04 15:42  wwlww  阅读(169)  评论(0编辑  收藏  举报