1import string
2from random import *
3characters = string.ascii_letters + string.punctuation + string.digits
4password = "".join(choice(characters) for x in range(randint(8, 16)))
5print password
6
1import random
2letters = ['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']
3numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
4symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
5print("Welcome to the PyPassword Generator!")
6nr_letters = int(input("How many letters would you like in your password?\n"))
7nr_symbols = int(input(f"How many symbols would you like?\n"))
8nr_numbers = int(input(f"How many numbers would you like?\n"))
9password_list = []
10for char in range(1, nr_letters + 1):
11 password_list.append(random.choice(letters))
12for char in range(1, nr_symbols + 1):
13 password_list += random.choice(symbols)
14for char in range(1, nr_numbers + 1):
15 password_list += random.choice(numbers)
16
17random.shuffle(password_list)
18password = ""
19for char in password_list:
20 password += char
21print(f"Your password is: {password}")
1from tkinter import *
2import string
3from random import randint, choice
4
5def generate_password():
6 password_min = 8
7 password_max = 8
8 all_chars = string.ascii_letters + string.punctuation + string.digits
9 password = "".join(choice(all_chars) for x in range (randint(password_min, password_max)))
10 password_entry.delete(0, END)
11 password_entry.insert(0, password)
12
13def generate_password2():
14 password_min = 8
15 password_max = 8
16 all_chars = string.ascii_letters
17 password = "".join(choice(all_chars) for x in range (randint(password_min, password_max)))
18 password_entry.delete(0, END)
19 password_entry.insert(0, password)
20
21def generate_password3():
22 password_min = 8
23 password_max = 8
24 all_chars = string.ascii_letters + string.digits
25 password = "".join(choice(all_chars) for x in range (randint(password_min, password_max)))
26 password_entry.delete(0, END)
27 password_entry.insert(0, password)
28
29
30
31window = Tk()
32window.title("Generateur de mdp")
33window.geometry("720x480")
34window.minsize(1000, 600)
35window.wm_attributes("-topmost", 1)
36window.configure(bg = '#4065A4')
37
38frame = Frame(window, bg='#4065A4')
39
40
41
42salut = Label(frame, text="Le mdp va etre generer ici", font=("Helvetica", 20), bg='#4065A4', fg='white')
43salut.pack()
44
45password_entry = Entry(frame, text="Mot de passe", font=("Helvetica", 20), bg='#4065A4', fg='white')
46password_entry.pack()
47
48Moche = Label(frame, text="Appuyez sur le boutton ci-dessous pour générer un mdp avec des lettres, ponctuations et caracteres speciaux", font=("Helvetica", 20), bg='#4065A4', fg='white')
49Moche.pack()
50
51button = Button(frame, text="generer", font=("Helvetica", 20), bg='#4065A4', fg='red', command=generate_password)
52button.pack(fill=X)
53
54Moche = Label(frame, text="Appuyez sur le boutton ci-dessous pour générer un mdp avec uniquement des lettres", font=("Helvetica", 20), bg='#4065A4', fg='white')
55Moche.pack()
56
57button = Button(frame, text="generer", font=("Helvetica", 20), bg='#4065A4', fg='red', command=generate_password2)
58button.pack(fill=X)
59
60Moche = Label(frame, text="Appuyez sur le boutton ci-dessous pour générer un mdp avec des lettres et des chiffres", font=("Helvetica", 20), bg='#4065A4', fg='white')
61Moche.pack()
62
63button = Button(frame, text="generer", font=("Helvetica", 20), bg='#4065A4', fg='red', command=generate_password3)
64button.pack(fill=X)
65
66frame.pack(expand=YES)
67
68
69window.mainloop()