No Pass Php Code Created By Chatgpt To Create Random Passwords

No Pass Php Code Created By Chatgpt To Create Random Passwords

robertxxx

User
User ID
20338
Jul 7, 2023
43
39
#CR
14
  • Thread starter
  • Thread Author
  • #1
function generatePassword($length) {

$vowels = 'aeiou';

$consonants = 'bcdfghjklmnpqrstvwxyz';

$specialChars = '!@#$%^&*';

$password = '';

$vowelCount = strlen($vowels);

$consonantCount = strlen($consonants);

$specialCharCount = strlen($specialChars);



// Generate random indices for including uppercase, number, and special character

$upperIndex = rand(0, $length - 1);

$numberIndex = rand(0, $length - 1);

$specialCharIndex = rand(0, $length - 1);



// Ensure the indices are unique

while ($numberIndex === $upperIndex || $numberIndex === $specialCharIndex || $upperIndex === $specialCharIndex) {

$numberIndex = rand(0, $length - 1);

$specialCharIndex = rand(0, $length - 1);

}



for ($i = 0; $i < $length; $i++) {

if ($i === $upperIndex) {

$password .= strtoupper($consonants[rand(0, $consonantCount - 1)]);

} elseif ($i === $numberIndex) {

$password .= rand(0, 9);

} elseif ($i === $specialCharIndex) {

$password .= $specialChars[rand(0, $specialCharCount - 1)];

} else {

if ($i % 2 == 0) {

$password .= $consonants[rand(0, $consonantCount - 1)];

} else {

$password .= $vowels[rand(0, $vowelCount - 1)];

}

}

}



return $password;

}



$passwords = array();

for ($i = 0; $i < 8; $i++) {

$passwords[] = generatePassword(12);

}



?>









Password Generator



table {

border-collapse: collapse;

width: 50%;

}

th, td {

border: 1px solid black;

padding: 8px;

text-align: left;

}

th {

background-color: #f2f2f2;

}









Passwords









#

Password



$password): ?>
 
Back
Top Bottom