Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. '''
  2. Created on Jan 11, 2017
  3.  
  4. @author: tkelly
  5. '''
  6. #! python3
  7. # strongPasswordDetection.py - a program to verify that a password is strong
  8. # a strong password has: >8 characters, upper & lower case, and >1 digit
  9.  
  10. import re
  11.  
  12. pw = input("Please enter a password at least 8 characters long, containing at least 1 uppercase and 1 lowercase letter and at least 1 digit")
  13. capsReg = re.compile(r"[A-Z]")
  14. lowersReg = re.compile(r"[a-z]")
  15. digitsReg = re.compile(r"\d")
  16.  
  17. def strongPassword(password):
  18. if len(password) <8:
  19. print("Your password needs to be at least 8 characters long. Please try again")
  20. else:
  21. if capsReg.search(password) and lowersReg.search(password) and digitsReg.search(password):
  22. return True
  23. else:
  24. return False
  25.  
  26. print(strongPassword(pw))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement