xxxxxxxxxx
$pass = random_password();
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
xxxxxxxxxx
function random_password($lower, $upper, $digits, $special_characters){
$lower_case = "abcdefghijklmnopqrstuvwxyz";
$upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$numbers = "1234567890";
$symbols = "!@#$%^&*";
$lower_case = str_shuffle($lower_case);
$upper_case = str_shuffle($upper_case);
$numbers = str_shuffle($numbers);
$symbols = str_shuffle($symbols);
$random_password = substr($lower_case, 0, $lower);
$random_password .= substr($upper_case, 0, $upper);
$random_password .= substr($numbers, 0, $digits);
$random_password .= substr($symbols, 0, $special_characters);
return str_shuffle($random_password);
}
$password = random_password(3,2,3,2);
echo $password;
xxxxxxxxxx
function generatePassword($length = 10) {
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?';
$password = '';
$characterCount = strlen($characters);
for ($i = 0; $i < $length; $i++) {
$password .= $characters[rand(0, $characterCount - 1)];
}
return $password;
}
// Generate a password with the default length of 10 characters
$password = generatePassword();
echo $password;