Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 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-=2
  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. score-=1
  51. else:
  52. print("You have enough special characters")
  53. score+=1
  54.  
  55. if len(password)<1:
  56. print("You didnt even enter a password you idiot")
  57. print("You have a score of ZERO")
  58. else:
  59. print("I would give your password a score of...",str(score),"Out of a possible 10\n")
  60. print("--------------------------------------------------------------")
  61. print("SOME TIPS:")
  62. if score>6:
  63. print("Well done, you seem to have a fairly strong password.")
  64. sleep(1)
  65. print("Brute force may not be the option here\n")
  66. else:
  67. print("Your password is a little too weak.\n")
  68. sleep(1)
  69. print("I'm sure it wouldn't take too long to crack this password with a computer\n")
  70.  
  71. if password in common:
  72. print("Please change your password at once, brute force would crack this in no time\n")
  73. password_check()
  74. again = input("Do u want to check another password?").lower()
  75. agreed = ["yes","yeah","y","yeh","da","oui","si","why not","sure","indeed","go ahead","righto","correct","of course"]
  76. if again in agreed:
  77. password_check()
  78. input("Press the enter key to exit")
  79. else:
  80. print("OK, goodbye")
  81. input("Press the enter key to exit")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement