BarBar288 commited on
Commit
2bef261
·
verified ·
1 Parent(s): a5b2fc6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random as r
3
+ import string
4
+
5
+ # Define character sets
6
+ lower_charset = string.ascii_lowercase
7
+ upper_charset = string.ascii_uppercase
8
+ digitset = string.digits
9
+ symbolset = '!@#$%^&*()-_=+~:;{}[]/|<>?'
10
+
11
+ # Define character set options
12
+ options = {
13
+ '1': ('Uppercase Letters Only', upper_charset),
14
+ '2': ('Lowercase Letters Only', lower_charset),
15
+ '3': ('Numbers Only', digitset),
16
+ '4': ('Symbols Only', symbolset),
17
+ '5': ('Uppercase and Lowercase Letters', upper_charset + lower_charset),
18
+ '6': ('Uppercase Letters and Numbers', upper_charset + digitset),
19
+ '7': ('Uppercase Letters and Symbols', upper_charset + symbolset),
20
+ '8': ('Lowercase Letters and Numbers', lower_charset + digitset),
21
+ '9': ('Lowercase Letters and Symbols', lower_charset + symbolset),
22
+ '10': ('Numbers and Symbols', digitset + symbolset),
23
+ '11': ('Symbols, Lowercase Letters, and Uppercase Letters', symbolset + lower_charset + upper_charset),
24
+ '12': ('Symbols, Lowercase Letters, and Numbers', symbolset + lower_charset + digitset),
25
+ '13': ('Symbols, Uppercase Letters, and Numbers', symbolset + upper_charset + digitset),
26
+ '14': ('All Characters', upper_charset + lower_charset + digitset + symbolset)
27
+ }
28
+
29
+ def generate_password(char_type, length):
30
+ if char_type not in options:
31
+ return "Invalid choice. Please select a valid option."
32
+
33
+ possible_chars = options[char_type][1]
34
+ generated_passwd = ''.join(r.choices(possible_chars, k=length))
35
+ return generated_passwd
36
+
37
+ # Create Gradio interface
38
+ iface = gr.Interface(
39
+ fn=generate_password,
40
+ inputs=[
41
+ gr.Dropdown(list(options.keys()), label="Choose the character set you want to use for your password", value='14'),
42
+ gr.Slider(1, 50, step=1, label="Enter the desired length of your password", value=12)
43
+ ],
44
+ outputs="text",
45
+ title="Password Generator",
46
+ description="Generate a strong password based on your chosen character set and length."
47
+ )
48
+
49
+ # Launch the interface
50
+ iface.launch()