#!/usr/bin/perl my $len; use strict; use CGI; my $q = new CGI; print $q->header(); my $template = $q->param('template'); $len = $q->param('len'); if (!$len) { $len = 30 + int(rand(100 - 30)); } if (!$template) { $template = "M"; } print << "HTML"; Password generator (without JS)

Password generator (without JS)

Click here for a password generator that does use JavaScript

Length:
HTML my $checked = "checked"; print qq() : print qq(>); print qq(lower case letter
\n); print qq() : print qq(>); print qq(upper case letter
\n); print qq() : print qq(>); print qq(mixed case letter
\n); print qq() : print qq(>); print qq(mixed case alphanumeric
\n); print qq() : print qq(>); print qq(lower case consonant
\n); print qq() : print qq(>); print qq(upper case consonant
\n); print qq() : print qq(>); print qq(lower case vowel
\n); print qq() : print qq(>); print qq(upper case vowel
\n); print qq() : print qq(>); print qq(number
\n); print qq() : print qq(>); print qq(punctuation mark
\n); print qq() : print qq(>); print qq(any character
\n); print qq(
\n); print qq(\n); print qq(
\n); if ($len !~ /^[0-9]+$/) { print "Length must be a number.
\n"; exit; } else { if ($len > 999) { print "Keep the length below 999.
\n"; exit; } else { if ($template !~ /^[l|L|m|M|c|C|v|V|n|p|a]$/) { print "Invalid data\n"; exit; } } } my @numbers = (0..9); my @punctuation = qw(. ? < > : @ / ! " % ^ & * ( ) - + = _); my @loweralpha = ('a'..'z'); my @upperalpha = ('A'..'Z'); my @mixedalpha = ('a'..'z','A'..'Z'); my @lowerconsonants = qw(b c d f g h j k l m n p q r s t v w x y z); my @upperconsonants = qw(B C D F G H J K L M N P Q R S T V W X Y Z); my @lowervowels = qw(a e i o u); my @uppervowels = qw(A E I O U); my @mixedalphanum = ('a'..'z','A'..'Z',0..9); my @all = (@mixedalpha, @numbers, @punctuation); my @p; my $symbols = { 'n' => \@numbers, 'p' => \@punctuation, 'l' => \@loweralpha, 'L' => \@upperalpha, 'm' => \@mixedalpha, 'M' => \@mixedalphanum, 'c' => \@lowerconsonants, 'C' => \@upperconsonants, 'v' => \@lowervowels, 'V' => \@uppervowels, 'a' => \@all, }; my $tmp; my $iteration = 0; my $results; foreach (1..10) { $iteration++; foreach (1..$len) { $tmp = $symbols->{$template}[rand @{$symbols->{$template}}]; while (!$tmp) { $tmp = $symbols->{$template}[rand @{$symbols->{$template}}]; } push(@p,$tmp); $tmp = ''; } for (@p) { $results .= $_; } $results =~ s/\s+$//; print qq(Password$iteration:
\n); $results = ''; @p = (); } print qq(

[source]

\n); print qq(\n);