generates a random strong password and copies it to clipboard.
()
| 14 | |
| 15 | # ---------------------------- PASSWORD GENERATOR ------------------------------- # |
| 16 | def 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 ------------------------------- # |
| 36 | def save(): |