This project stores passwords securely in a file and checks strength.
import json
import os
def check_strength(pw):
return len(pw) >= 8 and any(c.isdigit() for c in pw)
passwords = {}
if os.path.exists("passwords.json"):
with open("passwords.json") as f:
passwords = json.load(f)
site = input("Enter site name: ")
pw = input("Enter password: ")
if check_strength(pw):
passwords[site] = pw
with open("passwords.json", "w") as f:
json.dump(passwords, f)
print("Password saved!")
else:
print("Weak password. Try again.")
Next Lesson →