Advertisement
Guest User

Untitled

a guest
Feb 13th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import hashlib
  2.  
  3. # Some variable declaration
  4. userFound = False
  5. ind = 0
  6. logged_in = False
  7. # Get user list from txt file
  8. usertxt = open('users.txt', 'r')
  9. userlist = usertxt.read().split('\n')
  10. usertxt.close()
  11. # Get username from user, check if valid
  12. user = raw_input('Username: ')
  13. for line in userlist:
  14.     if user in line:
  15.         userFound = True
  16.         ind = userlist.index(line)
  17.         break
  18. # Get pass list from txt file
  19. passtxt = open('pass.txt', 'r')
  20. passlist = passtxt.read().split('\n')
  21. passtxt.close()
  22. pass_ = raw_input('Password: ')
  23. pass_ = hashlib.sha256(pass_).hexdigest()
  24. # Confirms if password is good or not, logs in if good
  25. if pass_ == passlist[ind]:
  26.     logged_in = True
  27.  
  28. if logged_in:
  29.     print "Log in succesful. Welcome %s." % user
  30. else:
  31.     print "Log in failed. Username or password incorrect."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement