Spaces:
Sleeping
Sleeping
add application file
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
import string
|
4 |
+
|
5 |
+
def generate_password(length=12):
|
6 |
+
if length < 4:
|
7 |
+
return "Password length should be at least 4 to include all character types."
|
8 |
+
|
9 |
+
lowercase = string.ascii_lowercase
|
10 |
+
uppercase = string.ascii_uppercase
|
11 |
+
digits = string.digits
|
12 |
+
special_chars = string.punctuation
|
13 |
+
|
14 |
+
password = [
|
15 |
+
random.choice(lowercase),
|
16 |
+
random.choice(uppercase),
|
17 |
+
random.choice(digits),
|
18 |
+
random.choice(special_chars),
|
19 |
+
]
|
20 |
+
|
21 |
+
all_chars = lowercase + uppercase + digits + special_chars
|
22 |
+
password += random.choices(all_chars, k=length - 4)
|
23 |
+
|
24 |
+
random.shuffle(password)
|
25 |
+
|
26 |
+
return ''.join(password)
|
27 |
+
|
28 |
+
st.title("Password Generator 🔑")
|
29 |
+
|
30 |
+
st.sidebar.header("Password Settings")
|
31 |
+
length = st.sidebar.slider("Password Length", min_value=4, max_value=50, value=12)
|
32 |
+
generate_btn = st.sidebar.button("Generate Password")
|
33 |
+
|
34 |
+
if generate_btn:
|
35 |
+
password = generate_password(length)
|
36 |
+
st.subheader("Generated Password")
|
37 |
+
st.code(password)
|
38 |
+
else:
|
39 |
+
st.write("Adjust the length and click 'Generate Password' to create a secure password.")
|