http://www.perlmonks.org?node_id=122351

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I need to veryify a UNIX user from a webpage. I am trying to compare the encrypted password entry in the password file with the one submitted on the webpage. I can never get a match, however. I'm using the standard encryption function:

sub encrypt { @saltset = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '.', '/'); $pass = $_[0]; $now = time; ($pert1, $pert2) = unpack("C2", "$username"); $week = $now / (60*60*24*7) + $pert1 + $pert2; $nsalt = $saltset[$week % 64] . $saltset[$now % 64]; $cryptpass = crypt($pass,$nsalt); return $cryptpass; }

However, this function uses the time to set the salt. So my question is, since this function will return a different encrypted password every time, how do I authenticate a user?