How to generate random password with PHP?

后端 未结 19 2231
栀梦
栀梦 2020-12-01 00:45

Or is there a software to auto generate random passwords?

19条回答
  •  旧时难觅i
    2020-12-01 01:24

    I use st_split and implode function:

    function genarateKey(){
        $limit= 8;
        $chars= 'abcdefghijklmnopqrstuvxwyz1234567890!@#$%^&*()_+=-[]{}\|ABCDEFGHIJKLMNOPQRSTUVXWYZ';
        $chararray= str_split($chars);
        $gen=array();
        for($i=0;$i<$limit;$i++){
            $index=rand(0,strlen($chars)-1);
            $gen[$i]= $chararray[$index];
        }
        return implode($gen); //converts array to string
    }
    

提交回复
热议问题