Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Import required libraries
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
# Function to analyze the strength of the entered password
|
| 6 |
+
def analyze_password_strength(password):
|
| 7 |
+
score = 0
|
| 8 |
+
# Increase score based on different criteria
|
| 9 |
+
if len(password) >= 8:
|
| 10 |
+
score += 1
|
| 11 |
+
if re.search("[a-z]", password) and re.search("[A-Z]", password):
|
| 12 |
+
score += 1
|
| 13 |
+
if re.search("[0-9]", password):
|
| 14 |
+
score += 1
|
| 15 |
+
if re.search("[!@#$%^&*(),.?\":{}|<>]", password):
|
| 16 |
+
score += 1
|
| 17 |
+
if len(password) >= 12:
|
| 18 |
+
score += 1 # Bonus points for length >= 12
|
| 19 |
+
|
| 20 |
+
return score
|
| 21 |
+
|
| 22 |
+
# Streamlit application UI
|
| 23 |
+
def main():
|
| 24 |
+
st.title("Password Strength Analyzer")
|
| 25 |
+
|
| 26 |
+
password = st.text_input("Enter your password", type="password")
|
| 27 |
+
|
| 28 |
+
if st.button("Analyze Password Strength"):
|
| 29 |
+
score = analyze_password_strength(password)
|
| 30 |
+
if score < 2:
|
| 31 |
+
st.error("Weak Password: Try mixing uppercase and lowercase letters, numbers, and special characters.")
|
| 32 |
+
elif score < 4:
|
| 33 |
+
st.warning("Medium Password: Good, but consider increasing the length or adding more unique characters for a stronger password.")
|
| 34 |
+
else:
|
| 35 |
+
st.success("Strong Password: Great job! Your password is strong. Remember, always keep your passwords secure and unique.")
|
| 36 |
+
|
| 37 |
+
# Run the application
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
main()
|