-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathDynamic_Password_Generator.py
49 lines (38 loc) · 1.5 KB
/
Dynamic_Password_Generator.py
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
from tkinter import *
import random, string
def generate_password():
password_strength = strength.get()
password_length = length.get()
if password_strength == "Weak":
if password_length < 6:
password_length = 6
password = ''.join(random.choices(string.ascii_letters, k=password_length))
elif password_strength == "Medium":
if password_length < 8:
password_length = 8
password = ''.join(random.choices(string.ascii_letters + string.digits, k=password_length))
else:
if password_length < 10:
password_length = 10
password = ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=password_length))
generated_password.set(password)
root = Tk()
root.geometry("400x280")
root.title("Password Generator")
title = StringVar()
label = Label(root, textvariable=title).pack()
title.set("Choose the strength and length of your password:")
strength = StringVar()
strength.set("Weak")
strength_label = Label(root, text="Strength:").pack()
strength_option = OptionMenu(root, strength, "Weak", "Medium", "Strong")
strength_option.pack()
length_label = Label(root, text="Length:").pack()
length = IntVar()
length.set(8)
length_entry = Entry(root, textvariable=length).pack()
generate_button = Button(root, text="Generate", command=generate_password).pack()
generated_password = StringVar()
generated_password_label = Label(root, textvariable=generated_password)
generated_password_label.pack()
root.mainloop()