Untitled
unknown
plain_text
21 days ago
1.0 kB
4
Indexable
import re def check_password_strength(password): length_criteria = len(password) >= 8 digit_criteria = bool(re.search(r'\d', password)) uppercase_criteria = bool(re.search(r'[A-Z]', password)) lowercase_criteria = bool(re.search(r'[a-z]', password)) special_char_criteria = bool(re.search(r'[!@#$%^&*(),.?":{}|<>]', password)) if (length_criteria and digit_criteria and uppercase_criteria and lowercase_criteria and special_char_criteria): return "Strong password!" else: return "Weak password. Consider the following:\n" \ "- At least 8 characters\n" \ "- At least one digit\n" \ "- At least one uppercase letter\n" \ "- At least one lowercase letter\n" \ "- At least one special character" def main(): password = input("Enter your password: ") result = check_password_strength(password) print(result) if __name__ == "__main__": main()
Editor is loading...
Leave a Comment