生成固定长随机码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;

}
关注作者公众号,获取更多资源!
赏作者一杯咖啡~