Wesley Geysels
Joined: 01 Mar 2004 Posts: 121 Location: Belgium
|
Posted: Mon Mar 01, 2004 1:31 am Post subject: Random Password Generator |
|
|
<?php
function random_char($type)
{
$lenght = sizeof($type);
$position = mt_rand(0, $lenght-1);
return($type[$position]);
}
function random_password($n)
{
mt_srand((double)microtime() * 1000000);
$vowel = array("b","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","z");
$doublevowel = array("bl","br","cl","cr","dr","fl","fr","gl","gn","gr","kl","kn","kr", "ph", "pr", "sh", "sj", "sk", "sl", "sm", "sn", "sp", "st", "tr", "vl", "vr", "zw");
$consonant = array("a","e","i","o","u");
$number = array("1","2","3","4","5","6","7","8","9","0");
for ($i = 0; $i < $n; $i++)
{
$password = "";
$password .= random_char($doublevowel);
$password .= random_char($consonant);
$password .= random_char($vowel);
$password .= random_char($consonant);
$password .= random_char($vowel);
$password .= random_char($number);
$password .= random_char($number);
print ("<LI>$password</LI>\n");
}
}
print("<HTML>\n");
print("<HEAD>\n");
print("<TITLE>Randow Password Generator</TITLE>");
print("</HEAD>\n");
print("<BODY>\n");
print ("<FORM action=\"$PHP_SELF\" method=\"post\">\n");
print ("How many passwords do you want to regenerate?\n");
print ("<INPUT type=\"text\" size=\"3\" name=\"n\">\n");
print ("<INPUT type=\"submit\" value=\"Go!\">\n");
print ("<UL>\n");
random_password($n);
print ("</UL>\n");
print("</BODY>\n");
print("</HTML>\n");
// End Script
?> |
|