From bb2b535195ef65fd4e091fe2ba32e0dc8293ae87 Mon Sep 17 00:00:00 2001 From: mrayanasim09 Date: Tue, 7 Jul 2026 14:07:07 +0000 Subject: [PATCH] :art: Format Python code with psf/black --- Game/colox.py | 5 ++++- Game/snake_game.py | 24 ++++++++++++++++++------ Utilities/network.py | 16 +++++++++------- Utilities/password.py | 14 +++++++++++--- Utilities/password_hash.py | 6 +++--- 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/Game/colox.py b/Game/colox.py index 0a22b20..8d6039c 100644 --- a/Game/colox.py +++ b/Game/colox.py @@ -72,7 +72,10 @@ # enemy position e_p = [width, random.randint(50, height - 50)] # nosec B311 -e1_p = [random.randint(width, width + 100), random.randint(50, height - 100)] # nosec B311 +e1_p = [ + random.randint(width, width + 100), + random.randint(50, height - 100), +] # nosec B311 # function for game_over diff --git a/Game/snake_game.py b/Game/snake_game.py index 1915b4c..8cb40c9 100644 --- a/Game/snake_game.py +++ b/Game/snake_game.py @@ -51,8 +51,12 @@ snake_length = 1 # Spawn the first food -food_x = round(random.randrange(0, window_width - segment_size) / 20.0) * 20.0 # nosec B311 -food_y = round(random.randrange(0, window_height - segment_size) / 20.0) * 20.0 # nosec B311 +food_x = ( + round(random.randrange(0, window_width - segment_size) / 20.0) * 20.0 +) # nosec B311 +food_y = ( + round(random.randrange(0, window_height - segment_size) / 20.0) * 20.0 +) # nosec B311 # Game over flag game_over = False @@ -87,8 +91,12 @@ # Play eat sound effect eat_sound.play() # Spawn new food - food_x = round(random.randrange(0, window_width - segment_size) / 20.0) * 20.0 # nosec B311 - food_y = round(random.randrange(0, window_height - segment_size) / 20.0) * 20.0 # nosec B311 + food_x = ( + round(random.randrange(0, window_width - segment_size) / 20.0) * 20.0 + ) # nosec B311 + food_y = ( + round(random.randrange(0, window_height - segment_size) / 20.0) * 20.0 + ) # nosec B311 # Create new segment and add to snake's body snake_segments.append((snake_head_x, snake_head_y)) @@ -171,11 +179,15 @@ snake_length = 1 # Spawn new food food_x = ( - round(random.randrange(0, window_width - segment_size) / 20.0) # nosec B311 + round( + random.randrange(0, window_width - segment_size) / 20.0 + ) # nosec B311 * 20.0 ) food_y = ( - round(random.randrange(0, window_height - segment_size) / 20.0) # nosec B311 + round( + random.randrange(0, window_height - segment_size) / 20.0 + ) # nosec B311 * 20.0 ) game_over = False diff --git a/Utilities/network.py b/Utilities/network.py index 3f9b834..21909a7 100644 --- a/Utilities/network.py +++ b/Utilities/network.py @@ -26,7 +26,7 @@ def get_wifi_profiles(): capture_output=True, text=True, shell=False, # nosec B603 - check=True + check=True, ) output = result.stdout @@ -63,7 +63,7 @@ def get_wifi_password(profile): """ if not profile: return None - + try: # Use full path to netsh.exe for security # shell=False is explicit (default in subprocess.run) @@ -72,7 +72,7 @@ def get_wifi_password(profile): capture_output=True, text=True, shell=False, # nosec B603 - check=True + check=True, ) output = result.stdout @@ -97,10 +97,10 @@ def get_wifi_password(profile): def main(): """Main function to display Wi-Fi profiles and passwords.""" # Check if running on Windows - if not sys.platform.startswith('win'): + if not sys.platform.startswith("win"): print("Error: This tool only works on Windows operating systems.") return - + # Get Wi-Fi profiles profiles = get_wifi_profiles() @@ -116,8 +116,10 @@ def main(): password = get_wifi_password(profile) print("{:<30} | {:<}".format(profile, password or "")) print("=" * 50) - - print("\nNote: This information is retrieved from your system's saved Wi-Fi profiles.") + + print( + "\nNote: This information is retrieved from your system's saved Wi-Fi profiles." + ) print("Keep this information secure and do not share it with others.") diff --git a/Utilities/password.py b/Utilities/password.py index 7801de2..9c89efd 100644 --- a/Utilities/password.py +++ b/Utilities/password.py @@ -17,7 +17,7 @@ warnings.warn( "MD5 is cryptographically broken and insecure. " "This tool can only attempt to crack MD5 hashes for educational purposes.", - UserWarning + UserWarning, ) try: with open(pass_doc, "r", errors="ignore") as pass_file: @@ -32,7 +32,11 @@ break except FileNotFoundError: - print("Error: " + pass_doc + " is not found. Please provide the correct file path.") + print( + "Error: " + + pass_doc + + " is not found. Please provide the correct file path." + ) quit() if not pass_found: @@ -48,7 +52,11 @@ pass_found = True break except FileNotFoundError: - print("Error: " + pass_doc + " is not found. Please provide the correct file path.") + print( + "Error: " + + pass_doc + + " is not found. Please provide the correct file path." + ) quit() except Exception as e: print(f"Error checking password: {e}") diff --git a/Utilities/password_hash.py b/Utilities/password_hash.py index 78999b6..77c47d8 100644 --- a/Utilities/password_hash.py +++ b/Utilities/password_hash.py @@ -16,13 +16,13 @@ str2hash = input("Enter password to hash: ") # Check if user wants MD5 (for educational purposes only) -use_md5 = input("Use MD5 (insecure)? (y/n): ").lower() == 'y' +use_md5 = input("Use MD5 (insecure)? (y/n): ").lower() == "y" if use_md5: warnings.warn( "MD5 is cryptographically broken and should NOT be used for password hashing. " "Use bcrypt instead. This is for educational purposes only.", - UserWarning + UserWarning, ) # Using MD5 only for educational demonstration result = hashlib.md5(str2hash.encode()) # nosec B324 @@ -36,7 +36,7 @@ print("The bcrypt hash is: ", end="") print(hashed.decode()) print("\nThis is a secure hash. Store this in your database.") - + # Demonstrate verification print("\nTo verify a password against this hash, use:") print("bcrypt.checkpw(password.encode(), hashed_password.encode())")