SumairaArain commited on
Commit
d3f9deb
Β·
verified Β·
1 Parent(s): b6c7651

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -30
app.py CHANGED
@@ -2,30 +2,19 @@ import streamlit as st
2
  import random
3
  import string
4
 
5
- # Session state for storing passwords
 
 
 
6
  if "saved_passwords" not in st.session_state:
7
  st.session_state.saved_passwords = []
8
 
 
9
  # Dark mode toggle
10
  dark_mode = st.toggle("πŸŒ™ Dark Mode")
11
 
12
- if dark_mode:
13
- st.markdown(
14
- """
15
- <style>
16
- body {
17
- background-color: #0E1117;
18
- color: white;
19
- }
20
- </style>
21
- """,
22
- unsafe_allow_html=True
23
- )
24
-
25
  st.title("πŸ” Advanced Password Generator App")
26
 
27
- st.write("Generate strong passwords and manage them easily!")
28
-
29
  # Password length
30
  length = st.slider("Select Password Length", 4, 32, 12)
31
 
@@ -50,7 +39,7 @@ if symbols:
50
  characters += string.punctuation
51
 
52
 
53
- # Password strength checker function
54
  def check_strength(password):
55
 
56
  strength = 0
@@ -75,29 +64,32 @@ def check_strength(password):
75
  return "Strong βœ…"
76
 
77
 
78
- # Generate password
79
  if st.button("Generate Password"):
80
 
81
  if characters == "":
82
  st.warning("Please select at least one option!")
83
 
84
  else:
85
- password = ''.join(random.choice(characters) for _ in range(length))
 
 
 
86
 
87
- st.success("Generated Password:")
88
- st.code(password)
89
 
90
- # Strength check
91
- strength = check_strength(password)
92
- st.write("Password Strength:", strength)
93
 
94
- # Copy button
95
- st.code("Copy manually from above ☝️")
96
 
97
- # Save password button
98
- if st.button("Save Password"):
99
- st.session_state.saved_passwords.append(password)
100
- st.success("Password Saved Successfully!")
 
101
 
102
 
103
  # Show saved passwords
 
2
  import random
3
  import string
4
 
5
+ # Session state setup
6
+ if "generated_password" not in st.session_state:
7
+ st.session_state.generated_password = ""
8
+
9
  if "saved_passwords" not in st.session_state:
10
  st.session_state.saved_passwords = []
11
 
12
+
13
  # Dark mode toggle
14
  dark_mode = st.toggle("πŸŒ™ Dark Mode")
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  st.title("πŸ” Advanced Password Generator App")
17
 
 
 
18
  # Password length
19
  length = st.slider("Select Password Length", 4, 32, 12)
20
 
 
39
  characters += string.punctuation
40
 
41
 
42
+ # Password strength checker
43
  def check_strength(password):
44
 
45
  strength = 0
 
64
  return "Strong βœ…"
65
 
66
 
67
+ # Generate password button
68
  if st.button("Generate Password"):
69
 
70
  if characters == "":
71
  st.warning("Please select at least one option!")
72
 
73
  else:
74
+ st.session_state.generated_password = ''.join(
75
+ random.choice(characters) for _ in range(length)
76
+ )
77
+
78
 
79
+ # Show password (permanent display)
80
+ if st.session_state.generated_password:
81
 
82
+ st.success("Generated Password:")
83
+ st.code(st.session_state.generated_password)
 
84
 
85
+ strength = check_strength(st.session_state.generated_password)
86
+ st.write("Password Strength:", strength)
87
 
88
+ if st.button("Save Password"):
89
+ st.session_state.saved_passwords.append(
90
+ st.session_state.generated_password
91
+ )
92
+ st.success("Password Saved Successfully!")
93
 
94
 
95
  # Show saved passwords