Skip to main content

Password Generator (GUI)

Google gives you suggestions when you create your new passwords Right!

In the same way, python makes it too easy for you to create your own password generator rather than using other tools like google.

We are providing you the full source code with the explanation at every line which we are sure will help you.




# importing the tkinter module from tkinter import * # importing the pyperclip module to use it to copy our generated # password to clipboard import pyperclip # random module will be used in generating the random password import random # initializing the tkinter root = Tk() # setting the width and height of the gui root.geometry("400x400") # x is small case here # declaring a variable of string type and this variable will be # used to store the password generated passstr = StringVar() # declaring a variable of integer type which will be used to # store the length of the password entered by the user passlen = IntVar() # setting the length of the password to zero initially passlen.set(0) # function to generate the password def generate(): # storing the keys in a list which will be used to generate # the password pass1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')'] # declaring the empty string password = "" # loop to generate the random password of the length entered # by the user for x in range(passlen.get()): password = password + random.choice(pass1) # setting the password to the entry widget passstr.set(password) # function to copy the password to the clipboard def copytoclipboard(): random_password = passstr.get() pyperclip.copy(random_password) # Creating a text label widget Label(root, text="Password Generator Application", font="calibri 20 bold").pack() # Creating a text label widget Label(root, text="Enter password length").pack(pady=3) # Creating a entry widget to take password length entered by the # user Entry(root, textvariable=passlen).pack(pady=3) # button to call the generate function Button(root, text="Generate Password", command=generate).pack(pady=7) # entry widget to show the generated password Entry(root, textvariable=passstr).pack(pady=3) # button to call the copytoclipboard function Button(root, text="Copy to clipboard", command=copytoclipboard).pack() # mainloop() is an infinite loop used to run the application when # it's in ready state root.mainloop()




Comments

Popular posts from this blog

Drawing A Design In Python

 Code :  from turtle import *  from random import randint  bgcolor('black')  x = 1  speed(0)  while x < 400:      r = randint(0,255)   g = randint(0,255)    b = randint(0,255)      colormode(255)    pencolor(r,g,b)   fd(50 + x)   rt(90.991)   x = x+1     exitonclick() Result : 

PIKACHU

CODE FOR DRAWING THIS PIKACHU IS BELOW: import turtle def getPosition(x, y): turtle.setx(x) turtle.sety(y) print(x, y) class Pikachu: def __init__(self): self.t = turtle.Turtle() t = self.t t.pensize(3) t.speed(9) t.ondrag(getPosition) def noTrace_goto(self, x, y): self.t.penup() self.t.goto(x, y) self.t.pendown() def leftEye(self, x, y): self.noTrace_goto(x, y) t = self.t t.seth(0) t.fillcolor('#333333') t.begin_fill() t.circle(22) t.end_fill() self.noTrace_goto(x, y+10) t.fillcolor('#000000') t.begin_fill() t.circle(10) t.end_fill() self.noTrace_goto(x+6, y + 22) t.fillcolor('#ffffff') t.begin_fill() t.circle(10) t.end_fill() def rightEye(self, x, y): self.noTrace_goto(x, y) t = self.t ...

Drawing Doraemon

CODE:  from turtle import * def my_goto(x, y): penup() goto(x, y) pendown() def eyes(): fillcolor("#ffffff") begin_fill() tracer(False) a = 2.5 for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a -= 0.05 lt(3) fd(a) else: a += 0.05 lt(3) fd(a) tracer(True) end_fill() def beard(): my_goto(-32, 135) seth(165) fd(60) my_goto(-32, 125) seth(180) fd(60) my_goto(-32, 115) seth(193) fd(60) my_goto(37, 135) seth(15) fd(60) my_goto(37, 125) seth(0) fd(60) my_goto(37, 115) seth(-13) fd(60) def mouth(): my_goto(5, 148) seth(270) fd(100) seth(0) circle(120, 50) seth(230) circle(-120, 100) def scarf(): fillcolor('#e70010') begin_fill() seth(0) fd(200) circle(-5, 90) fd(10) circle(-5, 90) fd(20...