header image


have you seen this?

Triumph @ The Star Wars Episode II opening-thumbnail
Triumph @ The Star Wars Episode II opening

have you played this?

Awesome Tanks-thumbnail
Awesome Tanks

free money is always good, too...

need a quick, random password?

well, here's a script i wrote that generates a random password with a given number of characters, with the choice to select Upper case, Lower case, numberes and / or special characters.

try it out below, and if you like it, keep it. the source code is available to cut/paste below. all i ask is that you somehow link back to this page (or anywhere else on this site). enjoy!

number of characters (8+ for stronger passwords, 999 limit)
Use upper case characters (ABCD...)
Use lower case characters (abcd...)
Use numbers (0123...)
Use special characters ([email protected]#$...)


source code:
(); //start gathering data. prevents buffer overflow

function fGenerateRandomPassword($length,$useUpperCase,$useLowerCase,$useNumbers,$useSpecialChars)
//define strings for each category
$lowerCase strtolower($upperCase);
$numbers "0123456789";
$specialChars "[email protected]#$%^&*()?";

//adds characters from category if selected
$toUse "";
$countToUse 0;
$useUpperCase == "TRUE") { $toUse .= $upperCase$countToUse++; }
$useLowerCase == "TRUE") { $toUse .= $lowerCase$countToUse++; }
$useNumbers == "TRUE") { $toUse .= $numbers$countToUse++; }
$useSpecialChars == "TRUE") { $toUse .= $specialChars;  $countToUse++; }
preg_replace('/^\d+$/','',$length)==$length// check that only numbers are entered if javascript is disabled
"<b>Please enter only numbers in the field.</b>\n";
$length $countToUse//if number entered is less that the count of selected character sets.
"<b>\"number of characters\" can not be less than selection of characters to use.</b>\n";

//no errors, generate the password
$password "";
    for (
$i 0$i $length$i++)
$password .= $toUse[(rand() % strlen($toUse))];

//define the array to return
$passwordArray[0] = $password;
$passwordArray[1] = $upperCase;
$passwordArray[2] = $lowerCase;
$passwordArray[3] = $numbers;
$passwordArray[4] = $specialChars;

//check that the password contains at LEAST 1 character from each selected category
$hasUpper strpbrk($passwordArray[0],$passwordArray[1]);
$hasLower strpbrk($passwordArray[0],$passwordArray[2]);
$hasNumber strpbrk($passwordArray[0],$passwordArray[3]);
$hasSpecChar strpbrk($passwordArray[0],$passwordArray[4]);
$useUpperCase == "TRUE" && $hasUpper == "") || ($useLowerCase == "TRUE" && $hasLower == "") || ($useNumbers == "TRUE" && $hasNumber == "") || ($useSpecialChars == "TRUE" && $hasSpecChar == ""))

//it contains everything it needs... return the password
$password "Your password is: <b>".$passwordArray[0]."</b>\n";

$length $_POST['length'];
$countToUse 0;
$useUpper $_POST['useUpper'];
$useUpper == "on"$useUpper "TRUE";
$useLower $_POST['useLower'];
$useLower == "on"$useLower "TRUE";
$useNum $_POST['useNumbers'];
$useNum == "on"$useNum "TRUE";
$useSpec $_POST['useSpecialChars'];
$useSpec == "on"$useSpec "TRUE";

//make a password, and if it does not contain at least 1 character from each category, get a new password until it does.
$password fGenerateRandomPassword($length,$useUpper,$useLower,$useNum,$useSpec);
$password == "FALSE");

//display password
echo $password;
"<br /><br />\n------------------------------------------<br /><br />\n";

//display form for options. 'onkeyup' erases any non-numeric characters.
<form name="passwordGenerator" id="passwordGenerator" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<tr><td><input type="text" name="length" id="length" value="8" size="2" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"/></td><td>number of characters (8+ for stronger passwords, 999 limit)</td></tr>
<tr><td align="right"><input type="checkbox" name="useUpper" id="useUpper" checked/></td><td>Use upper case characters (ABCD...)</td></tr>
<tr><td align="right"><input type="checkbox" name="useLower" id="useLower" checked/></td><td>Use lower case characters (abcd...)</td></tr>
<tr><td align="right"><input type="checkbox" name="useNumbers" id="useNumbers" checked/></td><td>Use numbers (0123...)</td></tr>
<tr><td align="right"><input type="checkbox" name="useSpecialChars" id="useSpecialChars" checked/></td><td>Use special characters ([email protected]#$...)</td></tr>
<tr><td align="middle" colspan="2"><input type="submit" name="generatePassword" id="generatePassword" value="generate password"/>

(); //done gathering, let it all out!