Skip to content

Commit c7cb790

Browse files
Password Generator: add length input, strength indicator, and copy-to-clipboard support
1 parent aa00fc0 commit c7cb790

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Password Generator/main.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from tkinter import *
22
from random import choice
33
import string
4+
import pyperclip
45

56
class App:
67
def __init__(self):
@@ -13,7 +14,8 @@ def __init__(self):
1314

1415
self.label()
1516
self.entry()
16-
self.button()
17+
self.options()
18+
self.buttons()
1719

1820
def label(self):
1921
label_title = Label(self.window, text='Welcome to password generator', font=('Courrier', 20), bg='gray', fg='black')
@@ -34,6 +36,18 @@ def generate_password(self):
3436
password+=choice(characters)
3537
self.password_entry.delete(0, END)
3638
self.password_entry.insert(0, password)
39+
40+
if length < 8:
41+
strength = "Weak"
42+
elif length < 12:
43+
strength = "Medium"
44+
else:
45+
strength = "Strong"
46+
self.strength_label.config(text=f"Strength: {strength}")
47+
48+
def copy_password(self):
49+
pyperclip.copy(self.password_entry.get())
50+
self.strength_label.config(text="Copied to clipboard!")
3751

3852
app = App()
3953
app.window.mainloop()

0 commit comments

Comments
 (0)