MCPcopy Index your code
hub / github.com/geekcomputers/Python / generate_password

Function generate_password

Password Manager Using Tkinter/main.py:16–33  ·  view source on GitHub ↗

generates a random strong password and copies it to clipboard.

()

Source from the content-addressed store, hash-verified

14
15# ---------------------------- PASSWORD GENERATOR ------------------------------- #
16def generate_password():
17 """generates a random strong password and copies it to clipboard."""
18 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']
19 numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
20 symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
21
22 password_letters = [choice(letters) for _ in range(randint(8, 10))]
23 password_symbols = [choice(symbols) for _ in range(randint(2, 4))]
24 password_numbers = [choice(numbers) for _ in range(randint(2, 4))]
25
26 password_list = password_letters + password_symbols + password_numbers
27 shuffle(password_list)
28
29 password = "".join(password_list)
30 password_entry.delete(0, tk.END)
31 password_entry.insert(0, password)
32 pyperclip.copy(password)
33 messagebox.showinfo(title="Password Generated", message="Password copied to clipboard!")
34
35# ---------------------------- SAVE PASSWORD ------------------------------- #
36def save():

Callers

nothing calls this directly

Calls 3

deleteMethod · 0.45
insertMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected