Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- import re
- def password_check():
- print("Hello! And welcome to my password strength checker\n")
- print("Just type your password in and you will receive tips about how to make it better")
- print("--------------------------------------------------------------------------------")
- score = 5
- password = input("Enter a password please\n")
- nmatches = re.findall("[0-9]",password)
- print("You have",len (nmatches),"Numerical value(s) in your password")
- amatches = re.findall("[A-Z]",password)
- print("You have",len(amatches),"Upper case character(s) in your password")
- smatches = re.findall("[!-?]",password)
- print("You have",len(smatches)," special characters in yourpassword")
- print("Your password is",len(password),"character(s) long\n")
- print("---------------------------------------------------------")
- nums = len(nmatches)
- chars = len(amatches)
- if nums <2:
- print("You might want to include more numbers in your password\n")
- score-=1
- else:
- print("You have enough numbers in your password\n")
- score+=1
- if chars <2:
- print("You might want to include more capitals in your password\n")
- score-=1
- else:
- print("You have enough capitals\n")
- score+=1
- common = ["qwerty","1234","123456","password","password123","asdf","Password123","PASSword123","PASSWORD","abcdef","incorrect"]
- if password in common:
- print("Your password is a common password!!\n")
- score-=2
- else:
- print("Your password does not seem to be a common password\n")
- score+=1
- if len(password)<8:
- print("Your password is too short!")
- score-=2
- else:
- print("Your password's length is fine")
- score+=1
- if len(smatches) <1:
- print("You have no special characters!")
- score-=1
- else:
- print("You have enough special characters")
- score+=1
- if len(password)<1:
- print("You didnt even enter a password you idiot")
- print("You have a score of ZERO")
- else:
- print("I would give your password a score of...",str(score),"Out of a possible 10\n")
- print("--------------------------------------------------------------")
- print("SOME TIPS:")
- if score>6:
- print("Well done, you seem to have a fairly strong password.")
- sleep(1)
- print("Brute force may not be the option here\n")
- else:
- print("Your password is a little too weak.\n")
- sleep(1)
- print("I'm sure it wouldn't take too long to crack this password with a computer\n")
- if password in common:
- print("Please change your password at once, brute force would crack this in no time\n")
- password_check()
- again = input("Do u want to check another password?").lower()
- agreed = ["yes","yeah","y","yeh","da","oui","si","why not","sure","indeed","go ahead","righto","correct","of course"]
- if again in agreed:
- password_check()
- input("Press the enter key to exit")
- else:
- print("OK, goodbye")
- input("Press the enter key to exit")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement