Guest User

Untitled

a guest
Dec 11th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. # importing pickle
  2. import pickle
  3.  
  4. # defining variables
  5. create_username = 0
  6. create_password = 0
  7. password = 0
  8. username = 0
  9.  
  10. # this variable allows the user or denies the user to the rest of the program (will only run if access is 1)
  11. access = 0
  12.  
  13.  
  14. # creates a users dictionary
  15. with open('users.pickle', 'rb') as f:
  16. users = pickle.load(f)
  17.  
  18. print(users)
  19.  
  20. # sign up (creating new account)
  21. while username not in users and username != 'signup':
  22. username = input("enter username(type signup to create an account): ")
  23.  
  24. # add new user to dictionary
  25. if username == "signup" or username == "Signup":
  26. create_username = input("enter a new username: ")
  27. create_password = input("enter a new password (Your password cannot be the same as your username !!!!!!!): ")
  28.  
  29. if create_password in users:
  30. create_password = input("password taken re-enter: ")
  31. # then adds the new username to the users dictionary
  32. if username == 'signup':
  33. users[create_username] = create_password
  34.  
  35. if username in users:
  36. password = input("enter password: ")
  37.  
  38. if password in users:
  39. print("access granted")
  40.  
  41. access = 1
  42. if username not in users and username != 'signup':
  43. username = input("enter username: ")
  44.  
  45. if username in users:
  46. password = input("enter password")
  47.  
  48. if password in users:
  49. print("access granted")
  50. access = 1
  51.  
  52. if password not in users:
  53. print("access denied")
  54.  
  55. with open('users.pickle', 'wb') as f:
  56. # Pickle the 'data' dictionary using the highest protocol available.
  57. pickle.dump(users, f, pickle.HIGHEST_PROTOCOL)
  58.  
  59. print(users)
  60.  
  61. # importing pickle
  62.  
  63. # defining variables
  64. create_username = 0
  65. create_password = 0
  66. password = 0
  67. username = 0
  68.  
  69. print(users)
  70.  
  71. "enter username(type signup to create an account): "
  72.  
  73. if username == "signup" or username == "Signup":
Add Comment
Please, Sign In to add comment