# !perl
use CGI qw(:standard); # use the CGI libraries
print header; # start the html output
$username = param('username'); # take
$password = param('password'); # take
open(FILE, "./users/$username"); # open the user's file in $users
$passhash = ; # read the password hash from the file
close(FILE); # close the file
if (crypt($password, $passhash) eq $passhash) {
print "You are now logged in.";
} else {
print "Incorrect username or password, please try again.";
}
####
$salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z') [rand 64, rand 64];
# create random two-character salt
$passhash = crypt($password, $salt); # hash the password with the salt