7jimmy's picture
Create app.py
4b6744d verified
# Import required libraries
import streamlit as st
import re
# Function to analyze the strength of the entered password
def analyze_password_strength(password):
score = 0
# Increase score based on different criteria
if len(password) >= 8:
score += 1
if re.search("[a-z]", password) and re.search("[A-Z]", password):
score += 1
if re.search("[0-9]", password):
score += 1
if re.search("[!@#$%^&*(),.?\":{}|<>]", password):
score += 1
if len(password) >= 12:
score += 1 # Bonus points for length >= 12
return score
# Streamlit application UI
def main():
st.title("Password Strength Analyzer")
password = st.text_input("Enter your password", type="password")
if st.button("Analyze Password Strength"):
score = analyze_password_strength(password)
if score < 2:
st.error("Weak Password: Try mixing uppercase and lowercase letters, numbers, and special characters.")
elif score < 4:
st.warning("Medium Password: Good, but consider increasing the length or adding more unique characters for a stronger password.")
else:
st.success("Strong Password: Great job! Your password is strong. Remember, always keep your passwords secure and unique.")
# Run the application
if __name__ == "__main__":
main()