{
if($type==true)
{
$authnum = rand('100000','999999');
$count = db('user')->where('share_ma',$authnum)->count();
if($count>0 || in_array($authnum,['111111','222222','333333','444444','555555','666666','777777','888888','999999','000000','123456','654321']))
{
$authnum = getRandomString($len,$chars,$type);
}
}else{
srand((double)microtime()*1000000);//create a random number feed.
$ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
$list=explode(",",$ychar);
$authnum='';
for($i=0;$i<6;$i++){
$randnum=rand(0,35); // 10+26;
$authnum.=$list[$randnum];
}
}
return $authnum;
}
function randstring($len)
{
$str='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
$randStr = str_shuffle($str);
$rands= md5(time().$randStr);
return substr($rands,0,$len);
}
这是我后台的代码,生成的随机码是20位的MD5(171efe161e3983019915)
我想换成生成为明文的并且为8位数的数字,怎么改动,我是小白,还在研究中。。希望大神指点下。。
最佳答案