From 44db5a3b1267785cbf75d734aeb2ab980ac6048a Mon Sep 17 00:00:00 2001 From: MachinePainting Date: Thu, 29 Jan 2026 03:35:34 -0800 Subject: [PATCH] updated to universal drop/drive node --- scripts/win/decrypt_folder_win.py | 20 +++++----- scripts/win/encrypt_folder_win.py | 61 ++++++++++--------------------- 2 files changed, 30 insertions(+), 51 deletions(-) diff --git a/scripts/win/decrypt_folder_win.py b/scripts/win/decrypt_folder_win.py index d10add3..c178935 100644 --- a/scripts/win/decrypt_folder_win.py +++ b/scripts/win/decrypt_folder_win.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """ -DropSend Decryption Script for Windows +ComfyUI Encryption Scripts - Decryption (Windows) +Works with both DropSend and DriveSend nodes Decrypts .enc files using a key from environment variable or manual input """ @@ -18,10 +19,14 @@ except ImportError: def get_encryption_key(): """Get encryption key from environment variable or user input.""" - # Try environment variable first - key = os.environ.get('DROPSEND_ENCRYPTION_KEY') + # Try multiple environment variable names for compatibility + key = (os.environ.get('COMFYUI_ENCRYPTION_KEY') or + os.environ.get('comfyui_encryption_key') or + os.environ.get('DROPSEND_ENCRYPTION_KEY') or + os.environ.get('DRIVESEND_ENCRYPTION_KEY')) + if key: - print("Using key from DROPSEND_ENCRYPTION_KEY environment variable.") + print("Using key from environment variable.") return key # Prompt user @@ -32,7 +37,7 @@ def get_encryption_key(): print(" 1. Press Win + R, type 'sysdm.cpl', press Enter") print(" 2. Go to Advanced tab > Environment Variables") print(" 3. Under User variables, click New") - print(" 4. Variable name: DROPSEND_ENCRYPTION_KEY") + print(" 4. Variable name: COMFYUI_ENCRYPTION_KEY") print(" 5. Variable value: [your encryption key]") print(" 6. Click OK and restart any open terminals") print("") @@ -60,12 +65,11 @@ def decrypt_file(encrypted_path, output_path, fernet): def main(): - print("=== DropSend File Decryption (Windows) ===") + print("=== ComfyUI File Decryption (Windows) ===") print("") # Get folder path folder = input("Enter the folder path containing .enc files: ").strip() - # Remove surrounding quotes if present folder = folder.strip('"\'') if not folder or not os.path.isdir(folder): @@ -115,8 +119,6 @@ def main(): error_count = 0 for enc_path in enc_files: - # Remove .enc extension to get original filename - # The original extension is preserved (e.g., image.png.enc -> image.png) out_path = enc_path[:-4] # Remove .enc if decrypt_file(enc_path, out_path, fernet): diff --git a/scripts/win/encrypt_folder_win.py b/scripts/win/encrypt_folder_win.py index f8abee0..0fd5b5d 100644 --- a/scripts/win/encrypt_folder_win.py +++ b/scripts/win/encrypt_folder_win.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 """ -DropSend Encryption Script for Windows +ComfyUI Encryption Scripts - Encryption (Windows) +Works with both DropSend and DriveSend nodes Encrypts image/video files using a key from environment variable or manual input NOTE: This script is for LOCAL USE ONLY - for encrypting files on your local machine -outside of ComfyUI. The DropSend node handles encryption automatically during upload. +outside of ComfyUI. The nodes handle encryption automatically during upload. """ import os @@ -18,30 +19,23 @@ except ImportError: sys.exit(1) -# Supported file extensions (matching DropSend node) SUPPORTED_EXTENSIONS = ('.png', '.jpg', '.jpeg', '.webp', '.gif', '.mp4', '.avi', '.mov') def get_encryption_key(): """Get encryption key from environment variable or user input.""" - # Try environment variable first - key = os.environ.get('DROPSEND_ENCRYPTION_KEY') + key = (os.environ.get('COMFYUI_ENCRYPTION_KEY') or + os.environ.get('comfyui_encryption_key') or + os.environ.get('DROPSEND_ENCRYPTION_KEY') or + os.environ.get('DRIVESEND_ENCRYPTION_KEY')) + if key: - print("Using key from DROPSEND_ENCRYPTION_KEY environment variable.") + print("Using key from environment variable.") return key - # Prompt user print("") print("Encryption key not found in environment.") print("") - print("To set up automatic key retrieval:") - print(" 1. Press Win + R, type 'sysdm.cpl', press Enter") - print(" 2. Go to Advanced tab > Environment Variables") - print(" 3. Under User variables, click New") - print(" 4. Variable name: DROPSEND_ENCRYPTION_KEY") - print(" 5. Variable value: [your encryption key]") - print(" 6. Click OK and restart any open terminals") - print("") key = input("Enter your encryption key: ").strip() if not key: @@ -66,30 +60,21 @@ def encrypt_file(input_path, output_path, fernet): def main(): - print("=== DropSend File Encryption (Windows) ===") + print("=== ComfyUI File Encryption (Windows) ===") print("") print("NOTE: This script is for LOCAL USE ONLY.") - print("The DropSend node handles encryption automatically during upload.") + print("The ComfyUI nodes handle encryption automatically during upload.") print("") - # Get folder path - folder = input("Enter the folder path containing files to encrypt: ").strip() - # Remove surrounding quotes if present - folder = folder.strip('"\'') + folder = input("Enter the folder path containing files to encrypt: ").strip().strip('"\'') if not folder or not os.path.isdir(folder): print(f"Error: '{folder}' is not a valid directory.") sys.exit(1) - print(f"Processing folder: {folder}") - print("") - - # Recursive option - recursive_input = input("Encrypt files recursively (including subfolders)? (Y/N): ").strip().upper() + recursive_input = input("Encrypt files recursively? (Y/N): ").strip().upper() recursive = recursive_input == 'Y' - # Get encryption key - print("") key = get_encryption_key() try: @@ -99,11 +84,8 @@ def main(): sys.exit(1) print("") - print("Scanning for supported files...") print(f"Supported formats: {', '.join(SUPPORTED_EXTENSIONS)}") - print("") - # Find all supported files files_to_encrypt = [] if recursive: for root, _, files in os.walk(folder): @@ -116,7 +98,7 @@ def main(): files_to_encrypt.append(os.path.join(folder, file)) if not files_to_encrypt: - print("No supported files found in the specified location.") + print("No supported files found.") sys.exit(0) print(f"Found {len(files_to_encrypt)} file(s) to encrypt.") @@ -131,24 +113,19 @@ def main(): try: if encrypt_file(file_path, temp_enc_path, fernet): - os.remove(file_path) # Delete original - os.rename(temp_enc_path, final_enc_path) # Rename to final - print(f" + Encrypted: {os.path.basename(file_path)} -> {os.path.basename(final_enc_path)}") + os.remove(file_path) + os.rename(temp_enc_path, final_enc_path) + print(f" + Encrypted: {os.path.basename(file_path)}") success_count += 1 else: error_count += 1 if os.path.exists(temp_enc_path): os.remove(temp_enc_path) except Exception as e: - print(f" X Error processing {os.path.basename(file_path)}: {e}") + print(f" X Error: {e}") error_count += 1 - if os.path.exists(temp_enc_path): - os.remove(temp_enc_path) - print("") - print(f"Encryption complete: {success_count} successful, {error_count} failed") - print("") - print("Done!") + print(f"\nEncryption complete: {success_count} successful, {error_count} failed") if __name__ == "__main__":