Advertisement
Guest User

Untitled

a guest
Oct 4th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. print "username: ";
  2. $username = <STDIN>;
  3. chomp $username;
  4. print "password: ";
  5. $password = <STDIN>;
  6. chomp $password;
  7.  
  8. #sanitize the username
  9. $username = substr $username, 0, 256; #takes first 256 characters
  10. $username =~ s/\W//g; #remove anything that's not a character
  11.  
  12. $password_file = "users/$username.password";
  13. if (!open F, "<$password_file") {
  14. print "Unknown username!";
  15. } else {
  16. $correct_password = <F>;
  17. chomp $correct_password;
  18. if ($password eq $correct_password) {
  19. print "You are authenticated\n";
  20. } else {
  21. print "Incorrect password!\n";
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement