User-defined functions for generating random passwords in php (reprinted and shared) and custom functions in php. Php user-defined function for generating random passwords (reprinted and shared), php user-defined function for generating random passwords. Release Date: edit: script school php generate random password User php generate random password user-defined function (reproduced and shared), php custom
Php user-defined function for generating random passwords
-
Release date: edit: script School
Php user-defined function for generating random passwords
Generate a random password function. the generated password is a random string of lowercase letters and numbers. The length can be customized.
The code is as follows: /*
* Php automatically generates a new password user-defined function (with instance demo)
Applicable environment: PHP5.2.x/mysql 5.0.x
Code author: xujiajay
Contact: xujiaphp@gmail.com
**/
Function genPassword ($ min = 5, $ max = 8)
{
$ Validchars = "abcdefghijklmnopqrstuvwxyz123456789 ";
$ Max_char = strlen ($ validchars)-1;
$ Length = mt_rand ($ min, $ max );
$ Password = "";
For ($ I = 0; $ I <$ length; $ I ++)
{
$ Password. = $ validchars [mt_rand (0, $ max_char)];
}
Return $ password;
}
Echo "new password:". genPassword ()."
";
Echo "new password:". genPassword (5, 10 )."
";
?>
This article