Password Generator in PYTHON




The following is tkinter (python GUI library) built app that generates any random strong password on entering the required length.


pyCode:-


from tkinter import *

import string

import random as ra

def generate():

length = int(e2.get())

e2.delete(0, END)

l = []

password = f"\n Your {length} digit password is: \n"

choices = "*@"+string.ascii_letters+string.digits

for i in choices:

l.append(i)

for s in range(length):

a = ra.randint(0, 65)

password += l[a]

e1.insert(INSERT, password)

root = Tk()

e1 = Text(root, bg = "greenyellow", fg = "red")

e2 = Entry(root, bg = "cyan", bd = 3, fg = "yellow")

Button(root, text = "generate", command = generate).pack()

e2.pack()

e1.pack()

root.mainloop()

Explanation

1. tkinter lib is imported to build GUI

2. string lib is imported to use ASCII letters and digits

3. random module is imported so that any random password of given length could be generated (ra.randint function is used in the given code)

4. generate() function is made to bind it with the generate button later in the program

5. entered length is taken and then the entry box is cleared in the next two lines

6. l=[] is for declaration of list

7. choices are declared (use of strong lib), random password is generated of entered length, password is inserted in the text field 

8. a GUI window is created and generate() function is binded with the generate button

@projectsofcode on Instagram


___________________







Comments

Popular posts from this blog

HangMan game in PYTHON

Tic-Tac-Toe (multiplayer) using pthon

Projects to consider as a bigener in PYTHON