Ever wondered if your password is really strong enough? In the age of cyber threats, having a secure password is more important than ever. In this tutorial, we’ll create a Password Strength Checker using Python that analyzes passwords based on various security criteria and tells you if it’s Weak, Moderate, or Strong.
We’ll use Python’s built-in re
(regular expressions) module to perform pattern matching and validate different rules for a good password.
Our program checks for:
-
Minimum Length – At least 8 characters.
-
Lowercase Letters – Ensures you have at least one lowercase character.
-
Uppercase Letters – Ensures you have at least one uppercase character.
-
Numbers – At least one digit is required.
-
Special Characters – Includes symbols like
@ # $ % ^ & + = !
.
Do check out the video tutorial of this project on my YouTube channel and do subscribe to support me! Thanks!
#Created by CodingPorium,2025
import re
def check_password_strength(password):
strength = 0
remarks = ""
# Criteria checks
length_error = len(password) < 8
lowercase_error = re.search("[a-z]", password) is None
uppercase_error = re.search("[A-Z]", password) is None
digit_error = re.search("[0-9]", password) is None
special_char_error = re.search("[@#$%^&+=!]", password) is None
# Count passed conditions
if not length_error:
strength += 1
if not lowercase_error:
strength += 1
if not uppercase_error:
strength += 1
if not digit_error:
strength += 1
if not special_char_error:
strength += 1
# Remarks based on strength
if strength == 5:
remarks = "STRONG Password"
elif strength >= 3:
remarks = "MODERATE Password"
else:
remarks = "WEAK Password"
# Display details
print("Password Strength Check Analysis")
print(f"-> Length OK : {not length_error}")
print(f"-> Has Lowercase : {not lowercase_error}")
print(f"-> Has Uppercase : {not uppercase_error}")
print(f"-> Has Digit : {not digit_error}")
print(f"-> Has Special Characters : {not special_char_error}")
print("\nResult:", remarks)
# --- Main Program ---
user_password = input("Enter your password to check strength : ")
check_password_strength(user_password)
Thanks for reading, do subscribe our YouTube channel to support us in providing more awesome projects with free source code!
Post a Comment