Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. import re
  2.  
  3. def loopstrength(pword):
  4.     if len(pword) < 8:
  5.         print("First test: not strong - password is too short.")
  6.         loopstr = False
  7.     else:
  8.         print("First test: strong")
  9.         loopstr = False
  10.     return loopstr
  11.  
  12. def regexstrength(pword):
  13.     regexstr = False
  14.     #At least 8 characters
  15.     regexlen = re.match(".{8}", pword)
  16.     #At least one upper
  17.     regexup = re.match(r"[A-Z]+", pword)
  18.     #At least one lower
  19.     regexlo = re.match(r"[a-z]+", pword)
  20.     #At least one digit
  21.     regexdi = re.match("[0-9]+", pword)
  22.    
  23.     if regexlen is None:
  24.         print("Second test: not strong - password is too short.")
  25.     elif regexup is None:
  26.         print("Second test: not strong - password must contain at least one uppercase character.")
  27.     elif regexlo is None:
  28.         print("Second test: not strong - password must contain at least one lowercase character.")
  29.     elif regexdi is None:
  30.         print("Second test: not strong - password must contain at least one digit.")
  31.     else:
  32.         print("Second test: strong")
  33.         regexstr == True
  34.     return regexstr
  35.  
  36. while True:
  37.     usrpword = input("Enter a password (or 'quit' to exit): ")
  38.     if usrpword == 'quit':
  39.         print()
  40.         break
  41.     loopstrength(usrpword)
  42.     regexstrength(usrpword)
  43.     print()
  44. print("Bye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement