Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import hashlib
  2.  
  3.  
  4. def hashpass(unhashed):
  5. hashedPass = hashlib.md5(unhashed.encode())
  6. return hashedPass.hexdigest()
  7.  
  8.  
  9. def validpass():
  10. length = False
  11. characters = False
  12. number = False
  13. while not length or not characters or not number:
  14. if not length:
  15. print("Password needs to be longer than 7 characters.")
  16. if not characters:
  17. print("Password need to include a capital.")
  18. if not number:
  19. print("Password needs to include a number.")
  20. passwordCheck = input("Enter password - ")
  21. for i in range(0, len(passwordCheck)):
  22. try:
  23. int(passwordCheck[i])
  24. number = True
  25. except ValueError:
  26. pass
  27. if len(passwordCheck) >= 7:
  28. length = True
  29. if not passwordCheck.islower():
  30. characters = True
  31. validHash = hashpass(passwordCheck)
  32. return validHash
  33.  
  34.  
  35. passwordFile = input('Enter the filename where the credentials are stored. - ')
  36. user_name = input("Enter the user's account name.")
  37. password = validpass()
  38. password1 = hashpass(input("Re-enter password - "))
  39. while (password != password1):
  40. print('Passwords do not match.')
  41. password1 = hashpass(input("Please re-enter - "))
  42. try:
  43. with open(passwordFile, 'w') as f:
  44. f.write('Username: {}\n'.format(user_name))
  45. f.write('Password: {}\n'.format(password))
  46. except OSError as e:
  47. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement