Advertisement
Guest User

Untitled

a guest
Jan 30th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. import random
  2. import time
  3. import os
  4. import hashlib
  5. import getpass
  6. global listUsers
  7. global listPass
  8. global LPassword
  9. global listHash
  10. listUsers = []
  11. listPass = []
  12. listHash = []
  13. '''
  14. def encryptList(username,password):
  15. for x in username:
  16. b = random.choice(username)
  17. c = random.choice(password)
  18. print(" {} {} {}".format(b,c,x))
  19. '''
  20.  
  21. def passwordHashing(password1):
  22. hash_object1 = hashlib.sha256(password1.encode())
  23. hex_dig1 = hash_object1.hexdigest()
  24. for x in listPass:
  25. hash_object = hashlib.sha256(x.encode())
  26. hex_dig = hash_object.hexdigest()
  27. listHash.append(hex_dig)
  28. return hex_dig1
  29.  
  30. def passwordDictHashing():
  31. for listPass in dict1:
  32. hash_object = hashlib.sha256(listPass.encode())
  33. hex_dig = hash_object.hexdigest()
  34. return hex_dig
  35.  
  36. def Register():
  37.  
  38. username = input("Your wished Username :")
  39. password = getpass.getpass('Your wished Password ::')
  40. listUsers.append(username)
  41. listPass.append(password)
  42. print("Successfully registered !")
  43. time.sleep(3)
  44. welcome()
  45.  
  46.  
  47. def welcome():
  48. os.system('cls' if os.name == 'nt' else 'clear')
  49. print("Welcome to matt and ivan's lasagna")
  50. print("Enter number : \n 1. Register \n 2. Login")
  51. answer = input()
  52. if answer =='1':
  53. Register()
  54. elif answer =='2':
  55. login()
  56. else:
  57. print("You are stupid")
  58. time.sleep(3)
  59. os.system('cls' if os.name == 'nt' else 'clear')
  60. welcome()
  61.  
  62. def login():
  63. Lusername = input("Username : ")
  64. LPassword = getpass.getpass("UPassword : ")
  65. BPassword = passwordHashing(LPassword)
  66. if Lusername in listUsers and BPassword in listHash:
  67. print("Logged in")
  68. time.sleep(3)
  69. loggedIn(Lusername)
  70. else:
  71. print("Please try again.")
  72. time.sleep(1)
  73. os.system('cls' if os.name == 'nt' else 'clear')
  74. login()
  75.  
  76. #print(username + " " + passowrd)
  77.  
  78. def loggedIn(Lusername):
  79. Lusername = Lusername
  80. dict1 = {"Usernames":listUsers, "Passwords":listPass, "HashList":listHash}
  81.  
  82.  
  83. os.system('cls' if os.name == 'nt' else 'clear')
  84. print("Welcome {}!".format(Lusername))
  85. print("What do you want to do ?\n1. See all users and passwords.\n 2. Return to the main menu.")
  86. answer = input()
  87. if answer == "1":
  88. print('List of usernames : {}'.format(dict1["Usernames"]))
  89. #print('List of passwords : {}'.format(dict1["Passwords"]))
  90. print('List of Hash : {}'.format(dict1["HashList"]))
  91. time.sleep(1)
  92. answer2 = input("Do you wish to remove an account ?Y/N: ")
  93. answer2 = answer2.lower()
  94. if answer2 == "y":
  95. print("In progress")
  96. elif answer2 == "n":
  97. loggedIn(Lusername)
  98. elif answer == "2":
  99. welcome()
  100.  
  101.  
  102.  
  103.  
  104.  
  105. '''
  106. def PasswordEncryption():
  107.  
  108. '''
  109. welcome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement