-
Notifications
You must be signed in to change notification settings - Fork 1
/
GeoPass.py
59 lines (45 loc) · 1.66 KB
/
GeoPass.py
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
import random
import tkinter as tk
import string
def generate_password(length):
letters_and_digits = string.ascii_letters + string.digits
return ''.join(random.choice(letters_and_digits) for _ in range(length))
def display_password(length):
password = generate_password(length)
password_display.config(text=f"""Password:
{password}""")
def copy_password():
# Hide the Tkinter window
root.withdraw()
# Clear the clipboard
root.clipboard_clear()
# Append only the password to the clipboard
# Use split to separate the text by a colon and take the second element
root.clipboard_append(password_display.cget("text").split(":")[1].strip())
# Update the Tkinter window
root.update()
# Main Window
root = tk.Tk()
root.title("GeoPass, v[1.1]")
root.geometry("450x450")
# Welcome message
welcome_message = tk.Label(root, text="""Welcome to
GeoPass""")
welcome_message.pack()
# Password Displaying Labels
password_display = tk.Label(root, text="")
password_display.pack()
# Buttons to Generate Passwords
button_10 = tk.Button(root, text="Generate 10 char. password", command=lambda: display_password(10))
button_10.pack()
button_25 = tk.Button(root, text="Generate 25 char. password", command=lambda: display_password(25))
button_25.pack()
button_50 = tk.Button(root, text="Generate 50 char. password", command=lambda: display_password(50))
button_50.pack()
button_75 = tk.Button(root, text="Generate 75 char. password", command=lambda: display_password(75))
button_75.pack()
# Button to Copy Password
button_copy = tk.Button(root, text="Copy password", command=copy_password)
button_copy.pack()
# Run the Tkinter event loop
root.mainloop()