TobyInkster.co.uk
Password Scripts
All of this software is distributed under the terms of the GNU GPL.
ToBePaGe
Toby's Beneficial Password Generator (ToBePaGe) is a PHP function to create pseudo-random passwords.
<?php
/*
* Toby's Beneficial Password Gen (a.k.a. ToBePaGe) v1.0.0
* =======================================================
*
* Usage:
* $password = pwd_gen($string);
*
* Where $string is the password pattern to use. Password patterns
* may include:
*
* %C- replaced with a uppercase consonant
* %c- lowercase consonant
* %K- same as %C, but also includes common combinations of
* consonants such as 'Sh', 'Ch' and 'Str'
* %V- uppercase vowel (includes Y)
* %v- lowercase vowel (includes y)
* %L- uppercase letter
* %l- lowercase letter
* %a- any letter
* %n- numeric digit
* %A- alphanumeric character
* %p- punctuation mark
* %P- punctuation or alphanumeric character
* %%- literal %
*
* Other characters in $string are treated literally.
*
* For example, pwd_gen("%K%v%c%%u") might generate any of the
* following:
*
* Straz%u
* Bil%u
* Fyp%u
*
* This function may be distributed under the terms of the GNU GPL
* http://www.gnu.org/copyleft/gpl.html
*
*/
function pwd_gen ($str) {
$replace['%'] = array('%');
$replace['C'] = array('B','C','D','F','G','H','J','K','L','M','N','P',
'Q','R','S','T','V','W','X','Z');
$replace['c'] = array('b','c','d','f','g','h','j','k','l','m','n','p',
'q','r','s','t','v','w','x','z');
$replace['K'] = array_merge($replace['C'], array('Sh','Ch','Th','St',
'Str','Ph','Tr','Br','Cr','Pr','Gr','Kr','Fr',
'Sl','Fl','Pl','Gl','Dr','Bl'));
$replace['V'] = array('A','E','I','O','U','Y');
$replace['v'] = array('a','e','i','o','u','y');
$replace['L'] = array_merge($replace['C'], $replace['V']);
$replace['l'] = array_merge($replace['c'], $replace['v']);
$replace['n'] = array('0','1','2','3','4','5','6','7','8','9');
$replace['A'] = array_merge($replace['L'], $replace['l'], $replace['n']);
$replace['a'] = array_merge($replace['L'], $replace['l']);
$replace['p'] = array('!','*','$','%','&','#','.',',',';',':','-',
'_','=','+','@','[',']','(',')','{','}','?');
$replace['P'] = array_merge($replace['A'], $replace['p']);
$r = '';
srand();
while ( strlen($str) ) {
$c = substr($str,0,1);
$str = substr($str,1);
if ($c == '%') {
$c = substr($str,0,1);
$str = substr($str,1);
$x = '';
while (strlen($x) < 1) {
$x = array_rand($replace[$c]);
}
$r .= $replace[$c][$x];
}
else { $r .= $c; }
}
return $r;
}
// print pwd_gen("%K%v%c%%u") . "\n";
?>
radioize.pl
Often, when passwords are printed it is difficult to tell the difference between, for example, a capital letter I, a lower-case l and a number 1. radioize.pl solves this problem by converting passwords into international radio speak. For example, "trg" becomes "TANGO, ROMEO, GOLF."
radioize.pl is a stand-alone Perl script.
#!/usr/bin/perl
%letters = (
'a' => 'alpha',
'b' => 'bravo',
'c' => 'charlie',
'd' => 'delta',
'e' => 'echo',
'f' => 'foxtrot',
'g' => 'golf',
'h' => 'hotel',
'i' => 'india',
'j' => 'juliet',
'k' => 'kilo',
'l' => 'lima',
'm' => 'mike',
'n' => 'november',
'o' => 'oscar',
'p' => 'papa',
'q' => 'quebec',
'r' => 'romeo',
's' => 'sierra',
't' => 'tango',
'u' => 'uniform',
'v' => 'victor',
'w' => 'whisky',
'x' => 'x-ray',
'y' => 'yankee',
'z' => 'zulu'
);
%numbers = (
'0' => 'naught',
'1' => 'one',
'2' => 'two',
'3' => 'three',
'4' => 'four',
'5' => 'five',
'6' => 'six',
'7' => 'seven',
'8' => 'eight',
'9' => 'nine'
);
%punctuation = (
'.' => 'stop',
',' => 'comma',
'?' => 'question',
'!' => 'bang',
'#' => 'hash',
':' => 'colon',
';' => 'semicolon',
'@' => 'at',
'&' => 'ampersand',
'%' => 'percent',
'$' => 'dollar',
'£' => 'pound',
'¤' => 'euro',
'^' => 'caret',
'*' => 'asterisk',
'(' => 'open parenthesis',
')' => 'close parenthesis',
'[' => 'open bracket',
']' => 'close bracket',
'{' => 'open brace',
'}' => 'close brace',
'~' => 'tilde',
'|' => 'pipe',
"'" => 'single quote',
'"' => 'double quote',
'`' => 'backtick',
'-' => 'dash',
'+' => 'plus',
'=' => 'equals',
'_' => 'underscore',
'/' => 'slash',
"\\" => 'backslash',
'<' => 'less than',
'>' => 'more than',
"\n" => 'new line',
"\t" => 'tab',
' ' => 'space'
);
$in = shift @ARGV;
$out = '';
while ($in ne '') {
$char = substr($in,0,1);
$in = substr($in,1);
$expand = '';
if ($char =~ m/[A-Z]/) {
$expand = 'capital ';
$char =~ tr/[A-Z]/[a-z]/;
}
if ($char =~ /[a-z]/) {
$expand .= $letters{$char};
} elsif ($char =~ /[0-9]/) {
$expand = $numbers{$char};
} else {
$expand = $punctuation{$char};
}
if ($in ne '') {
$expand .= ', ';
} else {
$expand .= '.';
}
$out .= $expand;
}
$out =~ tr/[a-z]/[A-Z]/;
print "$out\n";