20 Random Alphanumeric Passwords
The passwords:
EdCnKwwC74AzDz9KDtaQ
gGAQwYmLNqjaok9bsVYE
guzZhttPs6ozYuqo7DGT
h6EnrTZ84zgDsPwXVXFV
9C2GUyLz48YGhTcmt9cX
SBZWJk9sutLheQwo42uv
gGYCAEUTGEdCyTPhgeHp
YELexjJrxbEgVzGukZHc
KAvjxf3s3TSWX3wFEGE9
42RASA978LwzP8KtLEvQ
Q6VVNYUZmPRSvobAk7wr
j69XuWGJo6LwJdCKScTh
7y4dbBTaKkaWhF9vmCGE
3JxcrmCkVamh2MbBP84A
RfWhoZMfJLDYoRSWHqHH
N4hevTFnS9MuMUn4c3Sx
P48C3NVjzeMdmvG8h42y
uhrndErvjX9MuCGsQvrc
8b2gdULk6gvof8cZwKZq
ALgJBkCx6aHgq9ACmSYG
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);