Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. import random
  2. spechar="!@#$"
  3. lowers="abcdefghijklmnopqrstuvwxyz"
  4. uppers=lowers.upper()
  5. numbers="1234567890"
  6. def specs():
  7. return random.choice(spechar)
  8. def lower():
  9. return random.choice(lowers)
  10. def upper():
  11. return random.choice(uppers)
  12. def number():
  13. return random.choice(numbers)
  14.  
  15.  
  16. def pwgen():
  17. password=" "
  18.  
  19. funs = [specs, lower, upper, number]
  20. for i in range(10):
  21. password+=random.choice(funs)()
  22. return password
  23. pwgn=pwgen()
  24. print("Welcome to Password Generator! Here is your temporary password",pwgn)
  25.  
  26. def pwdchk():
  27.  
  28. spechar = "!@#$"
  29. lowers = "abcdefghijklmnopqrstuvwxyz"
  30. uppers = lowers.upper()
  31. numbers = "1234567890"
  32. password = input("Enter your new password with length 8 chars with combination of upper, lower, numbers and spec chars")
  33. if len(password)==8:
  34. if any([c in spechar for c in password]):
  35. if any([c in lowers for c in password]):
  36. if any([c in uppers for c in password]):
  37. if any([c in numbers for c in password]):
  38. print("Your password has been changed to ",password)
  39. return password
  40. else:
  41. print("Does your pwd contain numbers?")
  42. pwdchk()
  43. else:
  44. print("Does your pwd contain Uppercase?")
  45. pwdchk()
  46. else:
  47. print("Does your pwd contain Lowercase?")
  48. pwdchk()
  49. else:
  50. print("Does your pwd contain Special chars?")
  51. pwdchk()
  52. else:
  53. print("Does your pwd has 8 chars?")
  54. pwdchk()
  55.  
  56.  
  57. answer=input("\nDo you want to change your password? y/n")
  58. if answer=='y':
  59. attempts = 0
  60. while attempts<3:
  61. temp = input("Enter your temp password")
  62. if temp==pwgn:
  63. print("Thank You")
  64. break
  65. else:
  66. print("Sorry! Try again")
  67. attempts+=1
  68. new = pwdchk()
  69. else:
  70. print("Your password is same as temporary "+pwgen()+" when you login the next time")
  71. Contact GitHub API Training Shop Blog About
  72. © 2017 GitHub, Inc. Terms Privacy Security Status Help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement