Python Password Generator + Password Strength Checker
I made a simple Python password generator with a password strength checker.
Features:
- Generates random passwords
- Supports letters, numbers and symbols
- Checks password complexity
- Beginner friendly code
Made this as a small Python practice project.
Code:
import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + "!@#$%^&*"
password = ""
for i in range(length):
password += random.choice(characters)
return password
def check_strength(password):
score = 0
if len(password) >= 12:
score += 1
if any(c.isupper() for c in password):
score += 1
if any(c.islower() for c in password):
score += 1
if any(c.isdigit() for c in password):
score += 1
if any(c in "!@#$%^&*" for c in password):
score += 1
if score <= 2:
return "Weak"
elif score <= 4:
return "Medium"
else:
return "Strong"
length = int(input("Password length: "))
new_password = generate_password(length)
print("\nGenerated password:")
print(new_password)
print("Strength:")
print(check_strength(new_password))