Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "username: ";
- $username = <STDIN>;
- chomp $username;
- print "password: ";
- $password = <STDIN>;
- chomp $password;
- #sanitize the username
- $username = substr $username, 0, 256; #takes first 256 characters
- $username =~ s/\W//g; #remove anything that's not a character
- $password_file = "users/$username.password";
- if (!open F, "<$password_file") {
- print "Unknown username!";
- } else {
- $correct_password = <F>;
- chomp $correct_password;
- if ($password eq $correct_password) {
- print "You are authenticated\n";
- } else {
- print "Incorrect password!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement