-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
52 lines (43 loc) · 1.7 KB
/
app.py
File metadata and controls
52 lines (43 loc) · 1.7 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
import streamlit as st
import random
import string
# Function to generate password
def generate_password(length, include_uppercase, include_numbers, include_symbols):
lowercase = string.ascii_lowercase
uppercase = string.ascii_uppercase if include_uppercase else ""
numbers = string.digits if include_numbers else ""
symbols = string.punctuation if include_symbols else ""
# Combine all possible characters based on the user's preferences
all_chars = lowercase + uppercase + numbers + symbols
# Ensure the length of the password is at least 8 characters
length = max(length, 8)
# Generate the password
password = "".join(random.choices(all_chars, k=length))
return password
# Streamlit app
def app():
st.title("Password Generator")
st.markdown(
f"""
<style>
.stApp {{
background-image: url("https://preview.redd.it/3nb9h6xi0lx61.png?auto=webp&s=79a7a919428bad201cb8785dd8cceb935d3a4791");
background-attachment: fixed;
background-color: transparent;
background-size: cover;
}}
</style>
""",
unsafe_allow_html=True
)
# Get user preferences
length = st.slider("Length", min_value=8, max_value=32, value=12)
include_uppercase = st.checkbox("Include uppercase letters")
include_numbers = st.checkbox("Include numbers")
include_symbols = st.checkbox("Include symbols")
# Generate and display the password
if st.button("Generate"):
password = generate_password(length, include_uppercase, include_numbers, include_symbols)
st.success(f"Your password is: {password}")
if __name__ == "__main__":
app()