-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword.py
88 lines (62 loc) · 2.85 KB
/
password.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import random
# Import the module
import tkinter as tk
# Building the root window
base = tk.Tk()
# Save the length of the password
lowerNo = tk.IntVar()
capsNo = tk.IntVar()
specialNo = tk.IntVar()
numbersNo = tk.IntVar()
# Building the password using these conditions
def randomize():
lower = lowerNo.get()
caps = capsNo.get()
special = specialNo.get()
numbers = numbersNo.get()
counter = lower + caps + special + numbers
if counter > 20:
generated.config(text=" The total characters selcted exceeds the password limit! Try again")
return
char = []
char.extend(random.choices("abcdefghijklmnopqrstuvwxyz",k=lower))
char.extend(random.choices("ABCDEFGHIJKLMNOPQRSTUVWXYZ",k=caps))
char.extend(random.choices("0123456789",k=numbers))
char.extend(random.choices("+-=*&^%$#@!?><",k=special))
random.shuffle(char)
password = ''.join(char)
generated.config(text="Your password is: " + password)
# Window title and Dimensions
base.title("Python Password Generator")
base.geometry("650x1600")
# Labels with what the program is about and basic instructions
welcome = tk.Label(base,text = "Welcome to my randomized password generator!", font=('arial',20,'bold'))
welcome.grid(row=1,column=1, sticky= tk.W,pady=20, padx=80)
note = tk.Label(base,text = "NOTE: Your password CANNOT exceed 20 characters", font=('arial',15,'bold'))
note.grid(row=2,column=1,ipadx=30, ipady=10)
prompt = tk.Label(base,text = "Specify how many characters you want for each category!")
prompt.grid(row=20,column=1, pady=30)
#These are the different Entries
option1L = tk.Label(base,text = "LowerCases")
option1L.grid(row=30,column=1, pady=10,sticky=tk.W, padx= 200)
option1E = tk.Entry(base,textvariable = lowerNo, font=('arial',10))
option1E.grid(row=30,column=1, pady=10, sticky=tk.W, padx = 300)
option2L = tk.Label(base,text = "Captials")
option2L.grid(row=40,column=1, pady=10,sticky=tk.W, padx= 200)
option2E = tk.Entry(base,textvariable = capsNo, font=('arial',10))
option2E.grid(row=40,column=1, sticky=tk.W,pady=10, padx = 300)
option3L = tk.Label(base,text = "Numbers")
option3L.grid(row=50,column=1, pady=10,sticky=tk.W, padx= 200)
option3E = tk.Entry(base,textvariable = numbersNo, font=('arial',10))
option3E.grid(row=50,column=1, sticky=tk.W,padx = 300, pady=10)
option4L = tk.Label(base,text = "Special")
option4L.grid(row=60,column=1, pady=10,sticky=tk.W, padx= 200)
option4E = tk.Entry(base,textvariable = specialNo, font=('arial',10))
option4E.grid(row=60,column=1, sticky=tk.W,pady=10, padx = 300)
# Button to generate the password
button = tk.Button(base, text = "Generate a Password",command=randomize)
button.grid(row=90,column=1, sticky=tk.W,pady=10, padx = 300)
# Display message indicating the password generation
generated = tk.Label(base, text="")
generated.grid(row=110,column=1, sticky=tk.W,pady=10, padx = 300)
base.mainloop()