Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

RE: RE: Create encrypted passwords

by ducky (Scribe)
on Mar 28, 2000 at 23:34 UTC ( [id://6351]=note: print w/replies, xml ) Need Help??


in reply to RE: Create encrypted passwords
in thread Create encrypted passwords

Better still:

$salt = join '', ('a'..'z','A'..'Z',0..9,'.','/')[rand 64, rand 64] ;

-Ducky

Update: Ok, took me a year to come back and fix this, but it's fixed the way I'd do it today. =/

Replies are listed 'Best First'.
RE: RE: RE: Create encrypted passwords
by btrott (Parson) on Mar 28, 2000 at 23:50 UTC
    That doesn't work. You're taking an array slice (incorrectly), then assigning it to a scalar variable. You want something like this:
    my @chars = ('a'..'z', 'A'..'Z', 0..9, '.', '/'); my $salt = join '', @chars[rand @chars, rand @chars];
    Note the "@" before "chars"--that denotes an array slice. And since we're taking an array slice and want to end up with a scalar, we need to do a join.
RE: RE: RE: Create encrypted passwords
by chromatic (Archbishop) on Mar 28, 2000 at 23:42 UTC
    What if you want to expand the valid characters someday?
    @chars=(a..z,A..Z,0..9,'.','/'); $salt= join '', @chars[rand(@chars), rand(@chars)];
    or even
    my $elem = @chars; $salt = join '', @chars[rand($elem), rand($elem)];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6351]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-23 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found