in reply to How do I encrypt an Unix password?
This works, however, I don't believe it to be incredibly secure. It first creates what's called a salt, and uses feeds that into the crypt function. Also, since this came from camel 1, be sure to add in the "my" statements where appropriate :-)# Generate a Salt $fullname = "Users Name"; $now = time; ($pert1, $pert2) = unpack("C2", "$fullname"); $week = $now / (60*60*24*7) + $pert1 + $pert2; $salt = ($week % 64) + ($now % 64); $salt = sprintf("%lx", $salt); # Use crypt to encrypt our password $passwd = crypt($password, $salt);
I think that looks much nicer :-) That'll give you the encrypted password in a string. All you need to do then is figure out how to do the actual password update. Perhaps there is a system call for this? If not, you could always pipe it into the UNIX passwd command :-) HTHmy $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand + 64]; my $passwd = crypt($password, $salt);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I encrypt an Unix password?
by Abigail (Deacon) on Jun 27, 2001 at 03:18 UTC | |
by andreychek (Parson) on Jun 27, 2001 at 05:51 UTC | |
by Anonymous Monk on Jun 27, 2001 at 14:33 UTC |