Skip to content

Commit d0af7eb

Browse files
authored
Merge pull request #54 from IceTheDev2/code-cleaning-separate-module-for-password-strength-checking
Separation
2 parents c52d379 + cbabeac commit d0af7eb

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

code/password_strength/password_strength_gui.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import tkinter as tk
66
from tkinter.font import Font
77
import customtkinter
8+
from pynput.keyboard import Key, Controller
89

910
from password_strength import password_strength_logic as logic
1011
import diacritics_fix as fix
@@ -13,6 +14,8 @@
1314

1415
copy_button_y_offset = 30
1516

17+
keyboard = Controller()
18+
1619

1720
class PasswordStrengthFrame(customtkinter.CTkFrame):
1821
"""
@@ -110,3 +113,15 @@ def display_warnings(entry_box: customtkinter.CTkEntry, w_labels: list, event: t
110113
w_labels[index].configure(text=warning)
111114
for label in w_labels:
112115
label.grid(column=0, row=2 + w_labels.index(label), sticky='w')
116+
117+
118+
def paste_text() -> None:
119+
"""
120+
Called upon pressing the paste button,
121+
this function uses the keyboard module to simulate pressing CTRL and V to paste text into the input_box.
122+
"""
123+
# https://youtu.be/DTnz8wA6wpw
124+
keyboard.press(Key.ctrl_l)
125+
keyboard.press('v')
126+
keyboard.release(Key.ctrl_l)
127+
keyboard.release('v')

code/password_strength/password_strength_logic.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
"""
44
from __future__ import annotations
55
import string
6-
from pynput.keyboard import Key, Controller
76
from collections.abc import Iterable
87
from dataclasses import dataclass
98
from pathlib import Path
109

11-
keyboard = Controller()
12-
1310
# passwords.txt is from the https://github.com/danielmiessler/SecLists repository.
1411
# https://www.youtube.com/watch?v=DCaKj3eIrro
1512
passwords_file = Path('password_strength/passwords.txt')
@@ -142,15 +139,3 @@ def check_for_patterns_in_password() -> str:
142139
pattern_warning = check_for_patterns_in_password()
143140

144141
return [prevalence_warning, length_warning, complexity_warning, pattern_warning]
145-
146-
147-
def paste_text() -> None:
148-
"""
149-
Called upon pressing the paste button,
150-
this function uses the keyboard module to simulate pressing CTRL and V to paste text into the input_box.
151-
"""
152-
# https://youtu.be/DTnz8wA6wpw
153-
keyboard.press(Key.ctrl_l)
154-
keyboard.press('v')
155-
keyboard.release(Key.ctrl_l)
156-
keyboard.release('v')

0 commit comments

Comments
 (0)