#!/bin/bash # DropSend Encryption Script for Linux # Encrypts image/video files using a key from environment variable or Secret Service echo "=== DropSend File Encryption (Linux) ===" echo "" echo "Enter the folder path containing files to encrypt:" # Read folder path read -r FOLDER # Remove any surrounding quotes FOLDER=$(echo "$FOLDER" | sed "s/^['\"]//;s/['\"]$//") # Validate folder path if [ -z "$FOLDER" ] || [ ! -d "$FOLDER" ]; then echo "Error: '$FOLDER' is not a valid directory." exit 1 fi echo "Processing folder: $FOLDER" echo "" # Prompt for recursive option echo "Would you like to encrypt files recursively (including subfolders)? (Y/N)" read -r RECURSIVE_RESPONSE if [[ "$RECURSIVE_RESPONSE" == "Y" || "$RECURSIVE_RESPONSE" == "y" ]]; then RECURSIVE="true" else RECURSIVE="false" fi # Try to get key from environment variable echo "" echo "Retrieving encryption key..." KEY="${DROPSEND_ENCRYPTION_KEY:-}" # If not in environment, try secret-tool (GNOME Keyring / KWallet) if [ -z "$KEY" ] && command -v secret-tool &> /dev/null; then KEY=$(secret-tool lookup service DropSend username DropSend 2>/dev/null) if [ -n "$KEY" ]; then echo "Using key from Secret Service (GNOME Keyring/KWallet)." fi fi # If still no key, prompt user if [ -z "$KEY" ]; then echo "" echo "Encryption key not found in environment or Secret Service." echo "" echo "To set up automatic key retrieval, either:" echo " 1. Set environment variable: export DROPSEND_ENCRYPTION_KEY=\"your_key\"" echo " 2. Store with secret-tool: echo -n \"your_key\" | secret-tool store --label=\"DropSend\" service DropSend username DropSend" echo "" echo -n "Enter your encryption key: " read -r KEY if [ -z "$KEY" ]; then echo "Error: No key provided." exit 1 fi else echo "Key retrieved successfully." fi echo "" # Python script to encrypt supported files python3 - <