Smart Password Generator

By Gforce20 on Mar 24, 2008

Smart Password Generator: Better than the average random password generator.

This calculates a random password letter by letter; each letter is chosen based upon the previous one. It uses combinations of letters that are easy to pronounce and remember, but doesn't necessarily use a word bank, as that would make it prone to automatic password cracking bots.

The user can select up to 20 letters in his password and 10 numbers, as well as choosing where the numbers should be placed.
A typical 6-letter, 2-number password would look like "97glapra". The HTML is included in this snippet- if you use this, make sure it's saved as "index.php" (or else, change 'action="index.php"' to the desired name.)

The numbers are also less than random- as the number string gets longer, digits repeat more often.

Right now, it only generates lowercase letters, and doesn't include symbols. I'll update this code over the next week.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Smart Password Generator</title>
<style type="text/css">body{font-family: "Trebuchet MS", Verdana, Arial, "Times New Roman";}</style>
<META name="author" content="Gforce20">
<META name="description" content="Smart Password Generator">
<META name="copyright" content="Protected by Open Source Initiative (OSI): http://opensource.org">
<META http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<h1>Smart Password Generator</h1>
<form action="index.php" method="get">
<p>How many letters in your password?</p>
<input type="radio" name="ltr" value="0" />None
<input type="radio" name="ltr" value="1" />1
<input type="radio" name="ltr" value="2" />2
<input type="radio" name="ltr" value="3" />3
<input type="radio" name="ltr" value="4" />4
<input type="radio" name="ltr" value="5" />5
<input type="radio" name="ltr" value="6" />6
<input type="radio" name="ltr" value="7" />7
<input type="radio" name="ltr" value="8" />8
<input type="radio" name="ltr" value="9" />9
<input type="radio" name="ltr" value="10" />10
<input type="radio" name="ltr" value="11" />11
<input type="radio" name="ltr" value="12" />12
<input type="radio" name="ltr" value="13" />13
<input type="radio" name="ltr" value="14" />14
<input type="radio" name="ltr" value="15" />15
<input type="radio" name="ltr" value="16" />16
<input type="radio" name="ltr" value="17" />17
<input type="radio" name="ltr" value="18" />18
<input type="radio" name="ltr" value="19" />19
<input type="radio" name="ltr" value="20" />20
<p>How many numbers in your password?</p>
<input type="radio" name="num" value="0" />None
<input type="radio" name="num" value="1" />1
<input type="radio" name="num" value="2" />2
<input type="radio" name="num" value="3" />3
<input type="radio" name="num" value="4" />4
<input type="radio" name="num" value="5" />5
<input type="radio" name="num" value="6" />6
<input type="radio" name="num" value="7" />7
<input type="radio" name="num" value="8" />8
<input type="radio" name="num" value="9" />9
<input type="radio" name="num" value="10" />10
<p>Number position?</p>
<input type="radio" name="pos" value="1" />Beginning
<input type="radio" name="pos" value="2" />End
<input type="radio" name="pos" value="3" />Middle<p />
<input type="submit" value="Generate" />
</form>
<?php
$letters=$_GET["ltr"];
$numbers=$_GET["num"];
$position=$_GET["pos"];
if(strlen($letters)>0 && strlen($numbers)>0 && strlen($position)>0){

function vowel($vnum,$alsoa,$alsob,$alsoc) {
  if($vnum==1) { return "a"; }
  if($vnum==2) { return "e"; }
  if($vnum==3) { return "i"; }
  if($vnum==4) { return "o"; }
  if($vnum==5) { return "u"; }
  if($vnum==6) { return "y"; }
  if($vnum==7) { return $alsoa; }
  if($vnum==8) { return $alsob; }
  if($vnum==9) { return $alsoc; }
}

function cons() {
  $rtn = "a";
  while($rtn=="a" || $rtn=="e" || $rtn=="i" || $rtn=="o" || $rtn=="u" || $rtn=="y") { $rtn = chr(rand(98,122)); }
  return $rtn;
}

function strongnum($pnum,$of) {
  $ofof = 1;
  $rtn = chr(rand(49,57));
  if($pnum==chr(33)) { $pnum = chr(49); }
  while($ofof<$of) {
    if(rand(0,5)==0) { $rtn = $pnum; }
    $ofof++;
  }
  return $rtn;
}

if($letters > 0) {
  $ofletters=1;
  $now=chr(33);
  while($ofletters<=$letters) {
    $prev=$now;
    if($prev=="!" || $prev=="a" || $prev=="e" || $prev=="i" || $prev=="o" || $prev=="u" || $prev=="y") { $now = cons(); }
    elseif($prev=="b") { $now = vowel(rand(1,8),"l","r","!"); }
    elseif($prev=="c") { $now = vowel(rand(1,9),"h","l","r"); }
    elseif($prev=="d") { $now = vowel(rand(1,7),"r","!","!"); }
    elseif($prev=="f") { $now = vowel(rand(1,8),"r","l","!"); }
    elseif($prev=="g") { $now = vowel(rand(1,9),"h","l","r"); }
    elseif($prev=="p") { $now = vowel(rand(1,9),"h","l","r"); }
    elseif($prev=="q") { $now = chr(117); }
    elseif($prev=="s") { $now = vowel(rand(1,9),"c","l","m"); }
    elseif($prev=="t") { $now = vowel(rand(1,9),"h","r","w"); }
    elseif($prev=="w") { $now = vowel(rand(1,9),"h","l","r"); }
    else { $now = vowel(rand(1,6),"!","!","!"); }
    $ltrstring.=$now;
    $ofletters++;
  }
}

if($numbers > 0) {
  $ofnumbers=1;
  $now=chr(33);
  while($ofnumbers<=$numbers) {
    $prev=$now;
    if($prev==chr(33)) { $now = chr(rand(48,57)); }
    else { $now = strongnum($prev,$ofnumbers); }
    $numstring.=$now;
    $ofnumbers++;
  }
}

if($position==1) { $final=$numstring.$ltrstring; }
if($position==2) { $final=$ltrstring.$numstring; }
if($position==3) {
  $mid = rand(1,strlen($ltrstring)-1);
  $lleft = substr($ltrstring,0,$mid);
  $lright = substr($ltrstring,$mid);
  $final = $lleft . $numstring . $lright;
}
echo "Password: " . $final;
} ?><p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a></p>
</body>
</html>

Comments

Sign in to comment.
zamzam   -  Jan 13, 2010

hello i'm just a newbie , i want to asking about this script. is this script can hack any password ? how to use it or where i should to put it ?

thx ,

 Respond  
wizkidweb16   -  Jun 13, 2008

I got an error, but I\'m too lazy to figure out the problem. So, here it is:

Parse error: syntax error, unexpected T_STRING in /misc/14/909/026/608/user/web/area51.wizkidweb.com/nukegrounds/index.php on line 57
 Respond  
Gforce20   -  Mar 26, 2008

Something bad happened when this page was encoded.
The HTML replaced > characters with &#62 - so adding a number right after it made it &#621, 622, etc., which made the HTML entity 621 or 622, rather than the HTML entity 62, followed by a 1.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.