File size: 1,359 Bytes
4b6744d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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()
|