Guest User

Untitled

a guest
Aug 17th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. import random
  2. def pwgenerator():
  3. lower = 'abcdefghijklmnopqrstuvwxyz'
  4. up = lower.upper()
  5. special = "~!@#$%^&*()_-+=}{|[]\?/:;'<>,."
  6. password = ""
  7. for i in range(3):
  8. password += random.choice(lower)
  9. password += random.choice(up)
  10. password += random.choice(special)
  11. return password
  12. pwg = pwgenerator()
  13. print "Welcome to Password Generator 1.0!\nHere is your temporary password:" ,pwg
  14.  
  15. def password():
  16. x = raw_input("Enter your password: ")
  17. z = '1234567890'
  18. y = 'abcdefghijklmnopqrstuvwxyz'
  19. w = y.upper()
  20. special = "~!@#$%^&*()_-+=}{|[]\?/:;'<>,."
  21. if len(x)>9:
  22. if any([c in z for c in x]):
  23. if any([c in y for c in x]):
  24. if any ([c in w for c in x]):
  25. if any ([c in special for c in x]):
  26. print "Your password has been changed to < %s >" % x
  27. else:
  28. print "Does your password contain a special charcater? (~!@#$%^&*()_-+=}{|[]\?/:;'<>,.)"
  29. password()
  30. else:
  31. print "Does your password contain an uppercase letter?"
  32. password()
  33. else:
  34. print "Does your password contain a lowercase letter?"
  35. password()
  36. else:
  37. print "Does your password contain a number?"
  38. password()
  39. else:
  40. print "Is your password at least 9 characters long?"
  41. password()
  42.  
  43. def pwchecker():
  44. user = raw_input("Please enter your temporary password: ")
  45. attempts = 0
  46. while attempts < 3:
  47. if user != pwg:
  48. user = raw_input("Incorrect. Please enter it again: ")
  49. attempts += 1
  50. elif user == pwg:
  51. print "Your new password must be at least 9 characters long, contain an uppercase/lowercase letter, at least one number and a special character."
  52. password()
  53. break
  54. else:
  55. print "Too many incorrect entries!"
  56.  
  57. personal = raw_input("Would you like to change your password? (y/n) ")
  58. while personal != 'y' and personal != 'n':
  59. personal = raw_input("Sorry, what was that? (y/n)")
  60. if personal == 'y':
  61. pwchecker()
  62. elif personal == 'n':
  63. print "Your password will still be " ,pwg + " the next time you log in"
Add Comment
Please, Sign In to add comment