20 Random Alphanumeric Passwords
The passwords:
yoKCNtUReQbGqLD7oZoY
CLpm3rAJeHjE3pXQWtUr
HMyrWdTp4xeW2sNWgbuZ
JzaDPXNGyd6XWyKMXgxe
DuzBdSGqvwqzAKBsUFVv
NtafABTBCv7nAtTNnkWj
mkpEvvh9xf9T43VCECPT
BSehwCrYPSdDUt8MDxBh
ZMPCH8tWfbq9otW3B82w
mxZqaokCb8WDXG6KfyEP
9KwBPkuGxvotTeqMjn8N
husgAGXqhVnxym9GY4RW
J9NmLwYxfasZ7t29csFy
36JMnVHhzJm9aXNJMJ6r
2sHKGVEHyVBbA2MYFa8M
8wcabcSwSVA6eWyeTQZz
hfrdLneJB6oSqdaykdZ6
ddrV2gn8myFKvGUh9NbJ
4ZfgsFsACFoWK8MUjF3c
EnfrHYT49Xhp3fwxQQdx
The code for the class
<?php
/**
* Class PasswordGenerator
*/
class PasswordGenerator
{
public static $letters = "2346789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnopqrstuvwxyz";
public static $length = "20";
public $letters_array;
function __construct()
{
$this->letters_array = array();
for ($a = 0; $a < strlen(self::$letters); $a++) {
$this->letters_array[] = self::$letters[$a];
}
}
function make(): string
{
$password = '';
for ($i = 0; $i < self::$length; $i++) {
srand((float)microtime() * 10000000);
$password .= $this->letters_array[array_rand($this->letters_array)];
}
return $password;
}
function printOne()
{
print $this->make();
}
function printMany($num)
{
for ($i = 0; $i < $num; $i++) {
$this->printOne();
print "\n";
}
}
}
How to invoke the class
$PG = new PasswordGenerator();
$PG->printMany(20);