jeudi 14 avril 2022

How to generate different password each time i clicked the button python

I have 2 python files: 1, the password generator, and 2, the password manger.

In the password manger I am using tkinter. I want to retrieve a generated password each time I click on the the generate button that imports from password generator file. however each time each I clicked on the generate button the same password shows.

Is there a way to generate a different password each time I click on the generate button?

File 1: password generator:

#Password Generator Project
from random import  shuffle,choice,randint
letters = ['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']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']



password_list = []

password_list = [choice(letters) for char in range(randint(8,10))]

password_list += [choice(symbols) for char in range(randint(2,4))]



password_list += [choice(numbers) for char in range(randint(2,4))]


shuffle(password_list)

password = "".join(password_list)


file 2: password manger(PASSWORD GENERATOR Function):

from tkinter import  *
from tkinter import messagebox
import pyperclip
YELLOW = "#f7f5dd"

# ---------------------------- PASSWORD GENERATOR ------------------------------- #
def GENERATOR_PASSWORD():
    password_input.delete(0,END)
    import password_gen
    generated_password = password_gen.password
    password_input.insert(0,generated_password)
    pyperclip.copy(generated_password)




Aucun commentaire:

Enregistrer un commentaire