PHP generates random passwords (PHP custom functions)
-
time: 2015-12-16-20:43:49 Source: Network
Introduction: PHP Random password generation code, using PHP custom function to generate a specified length of random password, password rules for lowercase letters and numbers of random strings, the length can be customized.
Generates a random password function that generates a random string with a password of lowercase letters and numbers, which can be customized in length.
Copy CodeThe code is as follows: <?php
/*
* PHP automatically generate new password custom function (with example demo)
Applicable environment: Php5.2.x/mysql 5.0.x
Code Xujiajay
Contact information: [Email protected]
* */
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 (). " <br> ";
echo "New password:". Genpassword (5,10). " <br> ";
?> related articles
- Php method for generating six-digit random passwords
- PHP generates a random user name and password method, custom password character set
- A simple way to generate random passwords in PHP
- PHP generates a custom function for random user names and passwords
- PHP generates random password functions, php password generator
- PHP Random Password Function Introduction example
- Two ways to generate strong passwords in PHP
- Example of a function that generates random passwords in PHP
PHP generated random password (PHP custom function) from the Pioneer tutorial network