..


Sponsored Links

Is there a function to create random passwords with PHP?

PHP does not natively have a function to do this, however, is not very complex by themselves make a similar function.

For those interested to point out this article that explains a methodology for creating strings with random values ​​or, alternatively, a function I supply ready for use:






 random_password function ($ len) {



  



 $ Chars = "abcdefghijkmnopqrstuvwxyz023456789";



  



 srand ((double) microtime () * 1000000);

 

  



 $ I = 0; $ passwd ='';

 

  



 while ($ i <= $ len) {

 

    



 $ Num = rand ()% 33;

 

    



 $ Passwd .= substr ($ chars, $ num, 1);

 

    



 $ I + +;

 

  



 }

 

  



 return $ passwd;







 }



Random_password only parameter allowed by the function is the number of characters that will compose the string returned.

In the same category ...
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Sponsored Links