[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] YAGOLF: password generation



On Wed, Apr 11, 2001 at 10:07:28AM -0300, Filipe Brandenburger wrote:
> This probably was requested before, but I'd
> like to see the shortest cmdline to generate
> a password of 8 random alphanumeric characters.

Assuming we're not worrying about little things like warnings...

perl -le'print map{(A..Z,a..z,0..9)[rand 62]}1..8'

What is that, 50?

Actually, this is a weak password generator (precisely the sort of
thing that flaws most DES uses, restricted keyspace) because a
password can be any printable ASCII character.  You'd actually want to
do this...

perl -le'print map chr((33..126)[rand 93]),0..8'

Oddly enough, its shorter, 48, and has no warnings.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
Any sufficiently encapsulated hack is no longer a hack.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe