PHP Password Generator Script

Just a basic password generator. Select the characters you want to include, a length up to 50, and hit "Generate". Always a useful thing to have..

Select Characters

Lowercase A-Z
Uppercase A-Z
Numbers (0-9)
Special Characters (.-+=_,!@$#*%<>[]{})

Password Length

Your Password:
uxECRKlQy

Paranoid? https

Use It Yourself:

$alpha = "abcdefghijklmnopqrstuvwxyz";
$alpha_upper = strtoupper($alpha);
$numeric = "0123456789";
$special = ".-+=_,!@$#*%<>[]{}";
$chars = "";

if (isset($_POST['length'])){
    // if you want a form like above
    if (isset($_POST['alpha']) && $_POST['alpha'] == 'on')
        $chars .= $alpha;
    
    if (isset($_POST['alpha_upper']) && $_POST['alpha_upper'] == 'on')
        $chars .= $alpha_upper;
    
    if (isset($_POST['numeric']) && $_POST['numeric'] == 'on')
        $chars .= $numeric;
    
    if (isset($_POST['special']) && $_POST['special'] == 'on')
        $chars .= $special;
    
    $length = $_POST['length'];
}else{
    // default [a-zA-Z0-9]{9}
    $chars = $alpha . $alpha_upper . $numeric;
    $length = 9;
}


$chars = str_shuffle($chars);
$len = strlen($chars);
$pw = '';

for ($i=0;$i<$length;$i++)
        $pw .= substr($chars, rand(0, $len-1), 1);

// the finished password
$pw = str_shuffle($pw);