sub encrypt_passwd { my $pw=shift; # Seed random number generator. From Camel book p. 223. # This should be outside this function, in the program # initialization, otherwise calls to this function very # close in time will result in the same salt. srand ( time() ^ ($$ + ($$ << 15)) ); my @c=('a'..'z', 'A'..'Z', '0'..'9','.','/'); my $s=$c[rand(@c)].$c[rand(@c)]; return crypt($pw, $s); } sub verify_passwd { my ($epw, $pw)=@_; my $s=substr($epw,0,2); return $epw eq crypt($pw,$s); }