Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def loopstrength(pword):
- if len(pword) < 8:
- print("First test: not strong - password is too short.")
- loopstr = False
- else:
- print("First test: strong")
- loopstr = False
- return loopstr
- def regexstrength(pword):
- regexstr = False
- #At least 8 characters
- regexlen = re.match(".{8}", pword)
- #At least one upper
- regexup = re.match(r"[A-Z]+", pword)
- #At least one lower
- regexlo = re.match(r"[a-z]+", pword)
- #At least one digit
- regexdi = re.match("[0-9]+", pword)
- if regexlen is None:
- print("Second test: not strong - password is too short.")
- elif regexup is None:
- print("Second test: not strong - password must contain at least one uppercase character.")
- elif regexlo is None:
- print("Second test: not strong - password must contain at least one lowercase character.")
- elif regexdi is None:
- print("Second test: not strong - password must contain at least one digit.")
- else:
- print("Second test: strong")
- regexstr == True
- return regexstr
- while True:
- usrpword = input("Enter a password (or 'quit' to exit): ")
- if usrpword == 'quit':
- print()
- break
- loopstrength(usrpword)
- regexstrength(usrpword)
- print()
- print("Bye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement