131 lines
4.2 KiB
131 lines
4.2 KiB
from tkinter import *
|
|
import random
|
|
|
|
lst_alphabet = ['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']
|
|
lst_ALPHABET = ['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']
|
|
lst_chiffres = ['0','1','2','3','4','5','6','7','8','9']
|
|
lst_special = ['&','à','ç','_','-','è','é','*','§','@','µ','^','¨','$','£','=','.','œ']
|
|
|
|
def generer_mdp():#fonction de generation des mdps
|
|
global chaine
|
|
l_mdp = int(value1.get())
|
|
nbr_maj = int(value2.get())
|
|
nbr_chiffres = int(value3.get())
|
|
nbr_special = int(value4.get())
|
|
mdp = []
|
|
|
|
if nbr_maj + nbr_chiffres + nbr_special <= l_mdp:
|
|
for i in range(nbr_maj):
|
|
l_a = random.randint(0,(len(lst_ALPHABET)-1))
|
|
mdp.append(lst_ALPHABET[l_a])
|
|
|
|
for i in range(nbr_chiffres):
|
|
l_b = random.randint(0,(len(lst_chiffres)-1))
|
|
mdp.append(lst_chiffres[l_b])
|
|
|
|
for i in range(nbr_special):
|
|
l_c = random.randint(0,(len(lst_special)-1))
|
|
mdp.append(lst_special[l_c])
|
|
|
|
for i in range(l_mdp - len(mdp)):
|
|
l_d = random.randint(0,(len(lst_alphabet)-1))
|
|
mdp.append(lst_alphabet[l_d])
|
|
|
|
random.shuffle(mdp)
|
|
chaine = ''.join(mdp)
|
|
mdp_label.set(chaine)
|
|
|
|
else:
|
|
chaine = "impossible"
|
|
mdp_label.set(chaine)
|
|
|
|
def copie():#fonction copier coller dans le presse papier
|
|
global chaine
|
|
fenetre.clipboard_clear()
|
|
fenetre.clipboard_append(chaine)
|
|
|
|
bg_color="#8cc2e6"
|
|
bg_active_color="#8cc2e6"
|
|
fg_color="#ec5c33"
|
|
fg_active_color="#ec5c33"
|
|
str_color="white"
|
|
str_active_color="white"
|
|
|
|
w_elem=25
|
|
w_entry=30
|
|
|
|
fenetre = Tk()
|
|
fenetre.configure(bg=bg_color)
|
|
chaine = "aucun"
|
|
|
|
"""labels mdp"""
|
|
mdp_est = StringVar()
|
|
mdp_est.set("Le mot de passe est :")
|
|
|
|
label_mdp_est = Label(fenetre, textvariable = mdp_est, bg = fg_color, fg=str_color, width=w_elem)
|
|
label_mdp_est.grid(row=9, column= 0)
|
|
|
|
mdp_label = StringVar()
|
|
mdp_label.set(chaine)
|
|
|
|
label_mdp = Label(fenetre, textvariable = mdp_label, bg = fg_color, fg=str_color, width=w_elem, height=3)
|
|
label_mdp.grid(row=10, column= 0)
|
|
""""""
|
|
|
|
"""label + entry nombres de caracteres"""
|
|
label1 = Label(fenetre, text= "nombres de caracteres", bg = fg_color, fg=str_color, width=w_elem)
|
|
label1.grid(row=0, column= 0)
|
|
|
|
value1 = StringVar()
|
|
value1.set("10")
|
|
|
|
entre1 = Entry(fenetre, textvariable=value1, bg = fg_color, fg=str_color, width=w_entry)
|
|
entre1.grid(row=1, column= 0)
|
|
""""""
|
|
|
|
"""label + entry nombres de majuscules"""
|
|
label2 = Label(fenetre, text= "nombres de majuscules", bg = fg_color, fg=str_color, width=w_elem)
|
|
label2.grid(row=2, column= 0)
|
|
|
|
value2 = StringVar()
|
|
value2.set("1")
|
|
|
|
entre2 = Entry(fenetre, textvariable=value2, bg = fg_color, fg=str_color, width=w_entry)
|
|
entre2.grid(row=3, column= 0)
|
|
""""""
|
|
|
|
"""label + entry nombres de chiffres"""
|
|
label3 = Label(fenetre, text= "nombres de chiffres", bg = fg_color, fg=str_color, width=w_elem) #
|
|
label3.grid(row=4, column= 0)
|
|
|
|
value3 = StringVar()
|
|
value3.set("1")
|
|
|
|
entre3 = Entry(fenetre, textvariable=value3, bg = fg_color, fg=str_color, width=w_entry)
|
|
entre3.grid(row=5, column= 0)
|
|
""""""
|
|
|
|
"""label + entry nombres de caractere speciaux"""
|
|
label4 = Label(fenetre, text= "nombres de caractere speciaux", bg = fg_color, fg=str_color, width=w_elem)
|
|
label4.grid(row=6, column= 0)
|
|
|
|
value4 = StringVar()
|
|
value4.set("1")
|
|
|
|
entre4 = Entry(fenetre, text=value4, bg = fg_color, fg=str_color, width=w_entry)
|
|
entre4.grid(row=7, column= 0, padx=100)
|
|
""""""
|
|
|
|
"""bouton valider"""
|
|
boutonv = Button(text="valider", command=generer_mdp, bg = fg_color, fg=str_color, activebackground=fg_color, activeforeground=str_color, width=w_elem)
|
|
boutonv.grid(row = 8, column=0)
|
|
""""""
|
|
|
|
"""bouton presse papier"""
|
|
boutonpp = Button(text="copier dans le presse-papier", command=copie, bg = fg_color, fg=str_color, activebackground=fg_color, activeforeground=str_color, width=w_elem)
|
|
boutonpp.grid(row = 11, column=0)
|
|
""""""
|
|
|
|
fenetre.clipboard_clear()
|
|
fenetre.mainloop()
|
|
fenetre.destroy
|