Wednesday, December 22, 2010

My password generator code

Some people have asked me about the code for my password generator. Here it is:

use strict;
use warnings;

use Crypt::Random qw(makerandom_itv);
use HTML::Entities;

print "<pre>\n ";
print join( ' ', ('A'..'Z') );
print "\n +-", '--' x 25, "\n";

foreach my $x ('A'..'Z') {
print "$x|";
foreach my $y (0..25) {
print encode_entities(
chr(makerandom_itv( Strength => 1,
Uniform => 1,
Lower = >ord('!'),
Upper => ord('~')))), ' ';
}
print "\n";
}
print '</pre>';

Labels:

If you enjoyed this blog post, you might enjoy my travel book for people interested in science and technology: The Geek Atlas. Signed copies of The Geek Atlas are available. Looking for a new job? Try UseTheSource.

4 Comments:

Blogger Slack said...

Where does Crypt/Random.pm go? I downloaded it from CPAN and I tried putting it in: /System/Library/Perl/Extras/5.10.0 as well as in: /System/Library/Perl/5.10.0

4:02 PM  
Blogger John Graham-Cumming said...

I can't do generic Perl technical support. Please read http://www.cpan.org/modules/INSTALL.html or even better use the CPAN: http://theoryx5.uwinnipeg.ca/CPAN/perl/lib/CPAN.html

4:07 PM  
Blogger Slack said...

Perfect, Thanks, that is very helpful..

4:15 PM  
Blogger j said...

Although the code seems ok (I have NOT tested).

I will have added an extra randoness, with the operator doing some physical activity and timing it to the least precision digit.

9:12 PM  

Post a Comment

Links to this post:

Create a Link

<< Home