Master Password Generator
This article talks about Master Password Generator V1, a free Master Series
It also talks about incorporating the password generating subroutine, developed
for Master Password Generator V1, into your own scripts.
If you want to go straight to the product description page to try the demo
or download the program, here is the URL:
Automatic password generation can be desired for many and varied reasons.
Here are a few.
For webmasters selling downloadable
products, like ebooks or software, where a unique password is provided with
For personal use, when a password
is desired that's not easily guessable.
Membership software, where new members
must be assigned a password.
Master Password Generator V1
When you use Master Password Generator V1, you'll find three form fields
for numbers and five checkboxes.
The three form fields for numbers are all optional:
The number of passwords you want
generated. If not filled in, 1 is assumed.
The minimum length for each password.
If not filled in, 7 is assumed.
The maximum length for each password.
If not filled in, 7 is assumed.
As you can see, you can generate
any number of passwords, with variable lengths.
The checkboxes tell Master Password Generator V1 which character set or sets
to use when generating the password or passwords. At least one of the five
checkboxes must be checked:
A character set composed of digits.
If an alphabet set is also checked, the digits 0 and 1 are not included because
they can easily be confused with the letter O or the letter l.
A capitalized alphabet set, excluding
the letter O.
An alphabet set of lower-case characters,
excluding the letter l.
A set of non-alphanumeric printable
The space character.
Simply check the checkboxes you want
to use for your passwords. Then click the submit button.
Master Password Generator V1 is simple to install. Just verify that the first
line of the script points to the location of perl on your server, upload
the script, and give it 755 permissions. The README.txt file, included in
the download package, has instructions.
To use Master Password Generator V1, type its URL into your browser.
That URL will display the control panel in your browser.
The Password Generating Subroutine
The subroutine in Master Password Generator V1 that generates passwords is
To give your own script password generation functionality, paste the subroutine
into your script. Here is the subroutine in its entirety:
my($composition,$lowlength,$highlength) = @_;
return '' unless $composition;
my @p = split //,$composition;
my $arraylength = @p;
$lowlength = 7 if $lowlength < 1; # default to 7.
$highlength = 7 if $highlength < 1; # default to 7.
if($lowlength > $highlength)
($highlength,$lowlength) = ($lowlength,$highlength);
my $length = int(rand($highlength - $lowlength + 1));
$length += $lowlength;
my $password = '';
my $i = int(rand($arraylength));
$password .= $p[$i];
} # sub MakePassword
# end of subroutine
To use the subroutine, you have
to provide it with the set of characters from which to generate the password.
Optionally, you can also provide it with the minimum and maximum length for
the generated password. If you do not provide those numbers, 7 will be assumed
Here is a complete Perl script as an example of using the subroutine (paste
the subroutine into place where indicated):
my $characterset = 'abcdefghijklmnopqrstuvwxyz';
my $minimum = 5;
my $maximum = 9;
# Paste subroutine MakePassword() above this line.
my $password = MakePassword($characterset,$minimum,$maximum);
print "Content-type: text/plain\\n\\n";
# end of script
The script provides a character set, along with the minimum and maximum length,
to the subroutine. The subroutine generates the password and returns it to
be stored in the variable $password, which is then printed.
There you have it, easy password generation, in a stand-along program and
a subroutine to incorporate into your own scripts.
Copyright © 2002 Bontrager Connection, LLC
About the Author: