-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
51 lines (40 loc) · 1.2 KB
/
gui.py
File metadata and controls
51 lines (40 loc) · 1.2 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
import tkinter as tk
from tkinter import messagebox
import re
def check_strength():
password = entry.get()
strength = 0
msg = ""
if len(password) >= 8:
strength += 1
else:
msg += "Use at least 8 characters.\n"
if re.search(r'[A-Z]', password) and re.search(r'[a-z]', password):
strength += 1
else:
msg += "Use both uppercase and lowercase letters.\n"
if re.search(r'\d', password):
strength += 1
else:
msg += "Include numbers.\n"
if re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
strength += 1
else:
msg += "Include special characters.\n"
if strength == 4:
messagebox.showinfo("Result", "Strong password 💪")
elif strength == 3:
messagebox.showinfo("Result", "Moderate password 😐\n" + msg)
else:
messagebox.showwarning("Result", "Weak password ⚠️\n" + msg)
# GUI setup
root = tk.Tk()
root.title("Password Strength Checker")
root.geometry("300x150")
label = tk.Label(root, text="Enter your password:")
label.pack()
entry = tk.Entry(root, show="*", width=30)
entry.pack()
btn = tk.Button(root, text="Check Strength", command=check_strength)
btn.pack()
root.mainloop()