-
Notifications
You must be signed in to change notification settings - Fork 0
/
Password Generator
60 lines (40 loc) · 1.49 KB
/
Password Generator
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
from tkinter import *
from tkinter import messagebox
import string
import pyperclip
import random
def generate():
small_alphabets = string.ascii_lowercase
capital_alphabets = string.ascii_uppercase
numbers = string.digits
special_characters = string.punctuation
all_char = small_alphabets + capital_alphabets + numbers + special_characters
pass_length = int(length_Box.get())
clear()
entry.insert(0, random.sample(all_char, pass_length))
def copy():
random_password = entry.get()
pyperclip.copy(random_password)
messagebox.showinfo('Copied!', 'Password copied to clipboard!')
def clear():
entry.delete(0, 'end')
root = Tk()
root.geometry('400x330')
root.configure(background='lightblue')
lbl1 = Label(root, text='PASSWORD GENERATOR', font=('arial', 24, 'bold'), bg='lightblue')
lbl1.grid(pady=10)
lbl2 = Label(root, text='Select the length of password:', font='none', bg='lightblue')
lbl2.grid(pady=10)
length_Box = Spinbox(root, from_=5, to=20, width=10, font=8, bd=2)
length_Box.grid(pady=4)
btn = Button(root, text='GENERATE', bg='sky blue', command=generate)
btn.grid(pady=10)
lbl3 = Label(root, text='Generated Password:', font='none', bg='lightblue')
lbl3.grid(pady=(20, 10))
entry = Entry(root, font='arial')
entry.grid(pady=(0, 11))
btn1 = Button(root, text='COPY', bg='sky blue', command=copy)
btn1.grid(row=5, padx=(0, 42), pady=(0, 10), sticky='e')
btn1 = Button(root, text='CLEAR', bg='sky blue', command=clear)
btn1.grid(row=6)
root.mainloop()