You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.7 KiB
99 lines
2.7 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():
|
|
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)
|
|
|
|
fenetre = Tk()
|
|
chaine = "aucun"
|
|
mdp_label = StringVar()
|
|
mdp_label.set("Le mot de passe est "+chaine)
|
|
|
|
label = Label(fenetre, textvariable= mdp_label)
|
|
label.grid(row=0, column= 0)
|
|
|
|
""""""
|
|
value1 = StringVar()
|
|
value1.set("10")
|
|
|
|
label = Label(fenetre, text= "nombres de caracteres")
|
|
label.grid(row=1, column= 0)
|
|
|
|
entre1 = Entry(fenetre, textvariable=value1, width=30)
|
|
entre1.grid(row=2, column= 0)
|
|
""""""
|
|
|
|
""""""
|
|
value2 = StringVar()
|
|
value2.set("1")
|
|
|
|
label = Label(fenetre, text= "nombres de majuscules")
|
|
label.grid(row=3, column= 0)
|
|
|
|
entre2 = Entry(fenetre, textvariable=value2, width=30)
|
|
entre2.grid(row=4, column= 0)
|
|
""""""
|
|
|
|
""""""
|
|
value3 = StringVar()
|
|
value3.set("1")
|
|
|
|
label = Label(fenetre, text= "nombres de chiffres")
|
|
label.grid(row=5, column= 0)
|
|
|
|
entre3 = Entry(fenetre, textvariable=value3, width=30)
|
|
entre3.grid(row=6, column= 0)
|
|
""""""
|
|
|
|
""""""
|
|
value4 = StringVar()
|
|
value4.set("1")
|
|
|
|
label = Label(fenetre, text= "nombres de caractere speciaux")
|
|
label.grid(row=7, column= 0)
|
|
|
|
entre4 = Entry(fenetre, text=value4, width=30)
|
|
entre4.grid(row=8, column= 0)
|
|
|
|
""""""
|
|
bouton4 = Button(text="valider", command=generer_mdp)
|
|
bouton4.grid(row = 9, column=0)
|
|
""""""
|
|
|
|
fenetre.mainloop()
|
|
fenetre.destroy
|