Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. from time import sleep
  2. import re
  3. def password_check():
  4. print("Hello! And welcome to my password strength checker\n")
  5. print("Just type your password in and you will receive tips about how to make it better")
  6. print("--------------------------------------------------------------------------------")
  7.  
  8. score = 5
  9. password = input("Enter a password please\n")
  10. nmatches = re.findall("[0-9]",password)
  11. print("You have",len (nmatches),"Numerical value(s) in your password")
  12. amatches = re.findall("[A-Z]",password)
  13. print("You have",len(amatches),"Upper case character(s) in your password")
  14. smatches = re.findall("[!-?]",password)
  15. print("You have",len(smatches)," special characters in yourpassword")
  16. print("Your password is",len(password),"character(s) long\n")
  17. print("---------------------------------------------------------")
  18. nums = len(nmatches)
  19. chars = len(amatches)
  20. if nums <2:
  21. print("You might want to include more numbers in your password\n")
  22. score-=1
  23. else:
  24. print("You have enough numbers in your password\n")
  25. score+=1
  26.  
  27. if chars <2:
  28. print("You might want to include more capitals in your password\n")
  29. score-=1
  30. else:
  31. print("You have enough capitals\n")
  32. score+=1
  33.  
  34. common = ["qwerty","1234","123456","password","password123","asdf","Password123","PASSword123","PASSWORD","abcdef","incorrect"]
  35. if password in common:
  36. print("Your password is a common password!!\n")
  37. score-=2
  38. else:
  39. print("Your password does not seem to be a common password\n")
  40. score+=1
  41.  
  42. if len(password)<8:
  43. print("Your password is too short!")
  44. score-=1
  45. else:
  46. print("Your password's length is fine")
  47. score+=1
  48. if len(smatches) <1:
  49. print("You have no special characters!")
  50. else:
  51. print("You have enough special characters")
  52. score+=1
  53. print("I would give your password a score of...",str(score),"Out of a possible 10\n")
  54. print("--------------------------------------------------------------")
  55. print("SOME TIPS:")
  56. if score>6:
  57. print("Well done, you seem to have a fairly strong password.")
  58. sleep(1)
  59. print("Brute force may not be the option here\n")
  60. else:
  61. print("Your password is a little too weak.\n")
  62. sleep(1)
  63. print("I'm sure it wouldn't take too long to crack this password with a computer\n")
  64.  
  65. if password in common:
  66. print("Please change your password at once, brute force would crack this in no time\n")
  67. password_check()
  68. again = input("Do u want to check another password?").lower()
  69. agreed = ["yes","yeah","y","yeh","da","oui","si","why not","sure","indeed","go ahead","righto","correct","of course"]
  70. if again in agreed:
  71. password_check()
  72. input("Press the enter key to exit")
  73. else:
  74. print("OK, goodbye")
  75. input("Press the enter key to exit")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement