ARTLUNG LAB Share

January 3, 2009

20 Random Alphanumeric Passwords

The passwords:

No record is made of these passwords.



Deprecated: Implicit conversion from float 171879.99999999997 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43

Deprecated: Implicit conversion from float 172260.00000000003 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43

Deprecated: Implicit conversion from float 173090.00000000003 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43
edPmyPdDQSx639oxMxKN
Deprecated: Implicit conversion from float 173439.99999999997 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43
LYfr7XwXwdSTpobpNwrP 33vEGZXssaAFgwk4sScy
Deprecated: Implicit conversion from float 176490.00000000003 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43

Deprecated: Implicit conversion from float 177359.99999999997 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43
qprCsDQNa6fGeNrShbcj tvEYs3HDkGa9j4bkeBVV vdZ9RwCK4zyuVute8Tb3 Mf8TvLdg6dgjQJWjqQ9A 6ZtLfEbGoLZK9yA22t8L CbNNomBXk7Zd68bca8tz
Deprecated: Implicit conversion from float 185199.99999999997 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43
AcggmZvapXhUrXzW9Zzr feCQjAZGpBs4dDxrukQx j2ZkExMGRqGsBL2aoxYb kYvSkYwsYAEmetq67EUb bZTTDZoP3UUvXALZDUvJ kVcJ4yvjBvRwNxu7bea4
Deprecated: Implicit conversion from float 194429.99999999997 to int loses precision in /usr/home/crawberts/public_html/lab.artlung.com/web/password-maker/PasswordGenerator.php on line 43
A9Y9vHsrLq4GnANkzgjv ybstwsYSR7mtwFwLkWEF qsYNWzKumspU3tU9RhEC XWVQ4xX3Pk894uGsbrZe r2zUnRzLt6PXgzLQvvUM

The code for the class


<?php

/**
 * Class PasswordGenerator
 *
 * @category PHP
 * @package  Classes
 * @author   Joe Crawford <joe@artlung.com>
 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  Release: 1.0
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
class PasswordGenerator
{

    public static 
$letters "2346789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnopqrstuvwxyz";
    public static 
$length "20";
    public 
$letters_array;

    
/**
     * PasswordGenerator constructor.
     */
    
function __construct()
    {
        
$this->letters_array = array();

        for (
$a 0$a strlen(self::$letters); $a++) {
            
$this->letters_array[] = self::$letters[$a];
        }
    }


    
/**
     * Make password
     *
     * @return string
     */
    
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;

    }

    
/**
     * Print one password
     *
     * @return void
     */
    
function printOne()
    {
        print 
$this->make();
    }

    
/**
     * Print many passwords
     *
     * @param $num
     *
     * @return void
     */
    
function printMany($num)
    {
        for (
$i 0$i $num$i++) {
            
$this->printOne();
            print 
"\n";
        }
    }


}

How to invoke the class

$PG = new PasswordGenerator();
$PG->printMany(20);