-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodsoft task 3 password generator
More file actions
55 lines (41 loc) · 1.75 KB
/
codsoft task 3 password generator
File metadata and controls
55 lines (41 loc) · 1.75 KB
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
from tkinter import *
from tkinter import messagebox
import random
import string
class password:
def __init__(self,root):
self.f=Frame(root,height=500,width=600,bg='orchid')
self.f.propagate(0)
self.f.pack()
self.l1=Label(self.f,text="Enter the length-->",width=25,font=('courier',20,'bold'),fg='dodgerBlue',bg='orchid')
self.l1.place(x=20,y=120)
self.e1=Entry(self.f,width=10,font=('courier',20,'bold'),fg='dodgerBlue',bg='black')
self.e1.place(x=390,y=120)
self.B1=Button(self.f,text='Generate',width=10,font=('courier',20,'bold'),fg='dodgerBlue',bg='black',activebackground='dodgerBlue',activeforeground="hotpink")
self.B1.bind("<Button-1>",self.Passgen)
self.B1.place(x=200,y=200)
def Passgen(self,event):
if self.e1.get().strip() == "":
messagebox.showwarning("Missing Input", "Please enter the password length first!")
return
elif not self.e1.get().isdigit():
messagebox.showerror("Invalid Input", "Please enter a valid number!")
return
password=""
x=int(self.e1.get())
for i in range(0,x):
letters=string.ascii_letters
digit=string.digits
sym="@#$%&*"
allpass=letters+digit+sym
letter=random.choice(allpass)
password=password+letter
self.display(password)
def display (self,password):
word=password
l2=Label(self.f,text="Your generated password is--->"+word,width=50,height=1,font=('dancing script',20,'italic'),fg='red',bg='orchid',anchor='w')
l2.place(x=0,y=275)
root=Tk()
root.title("password_generator")
gen=password(root)
root.mainloop()