Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. username = input("Enter your username: ")
  2. password = input("Enter your password: ")
  3.  
  4. #hashing
  5. p = len(password)+3
  6. hashValue = 0
  7. for element in password:
  8. hashValue += ord(element)*(37**(p*3+2))
  9. p += 1
  10.  
  11. #file reading
  12. searchfile = open("users.txt","r")
  13. for line in searchfile:
  14. if username in line:
  15. print(line)
  16. passwordFile = searchfile.readline()
  17. print(passwordFile)
  18. if password == passwordFile:
  19. print("Succesfully logged in.")
  20. else:
  21. print("Denied.")
  22.  
  23. user1
  24. 5682064547402171341935718587051072007223952507159509922486300727280224437681256157289392848984758601859653014989196589
  25. user2
  26. 5459242799619652684746638604361187538149455998072046842553294309854609933784480688770064676790163754304952120716010653
  27.  
  28. upD = {}
  29.  
  30. with open ("users.txt") as f:
  31. for line in f:
  32. (key,val) = line.split()
  33. upD[key] = val
  34. print(upD)
  35. if password in upD[username]:
  36. print("Welcome.")
  37. else:
  38. print("Denied.")
  39.  
  40. user1 5682064547402171341935718587051072007223952507159509922486300727280224437681256157289392848984758601859653014989196589
  41. user2 5459242799619652684746638604361187538149455998072046842553294309854609933784480688770064676790163754304952120716010653
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement