-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword-generator.py
More file actions
78 lines (53 loc) · 2.11 KB
/
password-generator.py
File metadata and controls
78 lines (53 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# générateur de mot de passe aléatoire
# source : Coding Magazine n°23
# manipulation des chaines
import string
# manipulation des nombres aléatoires
import random
# manipulation des interfaces graphiques
from tkinter import *
# Fenêtre d'initialisation du projet
Screen = Tk()
Screen.geometry("500x300")
Screen.title("Générateur de mots de passe aléatoire")
# Titre du programme
Title = StringVar()
TitleLabel = Label(Screen, textvariable=Title).pack()
Title.set =("Générateur de mots de passe aléatoire")
# création des boutons radios
def SelectionOptions():
SelectionOptions = Choice.get()
Choice = IntVar()
Radiobutton1 = Radiobutton(Screen, text="faible", variable=Choice, value=1, command=SelectionOptions).pack(anchor=CENTER)
Radiobutton2 = Radiobutton(Screen, text="moyen", variable=Choice, value=2, command=SelectionOptions).pack(anchor=CENTER)
Radiobutton3 = Radiobutton(Screen, text="fort", variable=Choice, value=3, command=SelectionOptions).pack(anchor=CENTER)
LabelChoice = Label(Screen)
LabelChoice.pack
LengthLabel = StringVar()
LengthLabel.set("Longeur du mot de passe")
LengthTitle = Label(Screen, textvariable=LengthLabel).pack()
# Longueur du mot de passe
Value = IntVar()
SpinLength = Spinbox(Screen, from_=9, to_=25, textvariable=Value, width=14).pack()
# Logique du programme
Poor = string.ascii_uppercase+string.ascii_lowercase
Average = string.ascii_uppercase+string.ascii_lowercase+string.digits
Symbols="~'!@#$%^()_-+={[]}|_:;"
Advance = Poor+Average+Symbols
def PassGen():
if Choice.get() == 1:
return "".join(random.sample(Poor,Value.get()))
if Choice.get() == 2:
return "".join(random.sample(Average,Value.get()))
if Choice.get() == 3:
return "".join(random.sample(Advance,Value.get()))
# Bouton de génération du mot de passe
Lsum = Label(Screen, text="")
Lsum.pack(side=BOTTOM)
def CallBack():
Lsum.config(text=PassGen())
Password=str(CallBack())
PassGenButton = Button(Screen, text="Générer mot de passe", bd=5, height=2, command=CallBack, pady=3)
PassGenButton.pack()
# La boucle d'événement dans tkinter
Screen.mainloop()