SF-CLI - Secure File Encryption CLI/TUI Tool
A secure file encryption tool with password protection, supporting both command-line and terminal user interface modes.
Features
- ๐ Secure Encryption: AES-256-GCM encryption with Argon2 key derivation
- ๐ File & Directory Support: Encrypt/decrypt individual files or entire directories
- ๐๏ธ Compression: Built-in gzip compression for space efficiency
- ๐ Progress Tracking: Real-time progress bars for large file operations
- ๐ฅ๏ธ Dual Interface: Both CLI and interactive TUI modes
- ๐ Memory Safety: Secure key handling with automatic zeroization
- โก High Performance: Optimized for large files with streaming operations
- ๐งช Well Tested: Comprehensive unit and integration tests
- ๐ Watch Mode: Automatic encryption/decryption of new files in monitored directories
- ๐ฏ Smart Filtering: Process only specific file extensions or patterns
- ๐๏ธ Auto-cleanup: Optionally delete source files after processing
Installation
From Source
From Releases
Download the latest binary from the Releases page.
- Latest Development Build: Automatically updated with every push to main branch
- Stable Releases: Created when version tags (e.g., v1.0.0) are pushed
Usage
Command Line Interface
# Show help
# Encrypt a file with password prompt
# Encrypt with compression and custom output
# Encrypt with password from command line (not recommended for production)
# Decrypt a file
# Decrypt with compression
# Encrypt an entire directory
# Decrypt a directory
Watch Mode (Auto-encrypt/decrypt)
Watch mode monitors directories for file changes and automatically processes them:
# Watch directory and auto-encrypt new files
# Watch with target directory and delete source files
# Watch with file extension filtering (only .txt and .doc files)
# Process existing files on startup
# Watch directory and auto-decrypt encrypted files
# Watch decrypt with compression and delete source
Watch Mode Features:
- Auto-encryption: Monitors a directory and encrypts new files automatically
- Auto-decryption: Monitors a directory and decrypts encrypted files automatically
- Password once: Set password once at startup, no need to re-enter
- Target directory: Specify different output directory (defaults to same directory)
- Delete source: Optionally delete source files after processing
- Extension filtering: Only process files with specific extensions
- Process existing: Process files that already exist in the directory
- Compression support: Enable compression for encrypted files
- Live monitoring: Real-time file system watching with debouncing
Terminal User Interface (TUI)
Start the interactive mode:
# or simply
TUI Controls:
1
- Encrypt file/directory2
- Decrypt file/directoryEnter
- Confirm inputEsc
- Return to main menuq
- Quit application
Security Features
Encryption
- Algorithm: AES-256-GCM (Authenticated encryption)
- Key Derivation: Argon2 with random salt
- Random Nonce: Generated for each encryption operation
- Memory Security: Keys are zeroized after use
File Format
Encrypted files contain:
- Salt (32 bytes): Random salt for key derivation
- Nonce (12 bytes): Random nonce for AES-GCM
- Ciphertext: Encrypted data with authentication tag
Compression
- Algorithm: gzip compression
- When Applied: Before encryption for maximum security
- Benefits: Significant space savings for repetitive data
Examples
Basic File Encryption
# Create a test file
# Encrypt it
# Output: โ Encrypt secret.txt -> secret.sf (83 bytes)
# Decrypt it
# Output: โ Decrypt secret.sf -> secret (23 bytes)
Watch Mode Examples
# Setup watch directories
# Start watching for new documents to encrypt
&
# Add files to watch - they will be automatically encrypted
# Files automatically encrypted to /tmp/encrypted/
# Start watching encrypted directory for auto-decryption
&
# Any new .sf files in /tmp/encrypted will be auto-decrypted to /tmp/decrypted/
Advanced Watch Usage
# Watch only specific file types and delete originals
# Watch with compression
Compression Example
# Create a large repetitive file
# Encrypt with compression
# Achieves 95%+ compression ratio on repetitive data
Directory Encryption
# Create a directory with files
# Encrypt the entire directory
# Output: โ Encrypt my_docs -> my_docs.sf (218 bytes, compressed)
# Decrypt the directory
# Restores the complete directory structure
Performance
- Large Files: Streaming operations with progress tracking
- Memory Usage: Efficient buffering (64KB default buffer size)
- Compression Ratios: Up to 99%+ for repetitive data
- Speed: Optimized Rust implementation
Project Structure
sf-cli/
โโโ src/
โ โโโ crypto.rs # Encryption/decryption engine
โ โโโ compression.rs # Compression utilities
โ โโโ file_ops.rs # File and directory operations
โ โโโ progress.rs # Progress tracking
โ โโโ models.rs # Data structures
โ โโโ tui.rs # Terminal user interface
โ โโโ lib.rs # Library root
โ โโโ main.rs # CLI application
โโโ tests/ # Integration tests
โโโ examples/ # Usage examples
โโโ docs/ # Documentation
Development
Prerequisites
- Rust 1.70 or later
Building
Running Tests
Running Examples
Running Clippy (Linter)
Formatting Code
Version Management
SF-CLI includes an automated version management script for releasing new versions:
# Increment patch version (1.0.4 โ 1.0.5)
# Increment minor version (1.0.4 โ 1.1.0)
# Increment major version (1.0.4 โ 2.0.0)
# Test without making changes
The script automatically:
- Updates
Cargo.toml
version - Runs formatting, build, and tests
- Commits changes with standardized message
- Creates and pushes git tags
- Triggers the release workflow
See scripts/README.md
for detailed usage and options.
CI/CD
This project uses GitHub Actions for continuous integration and deployment:
Workflows
-
CI: Runs on every push and pull request to main
- Tests, linting (clippy), formatting checks
- Multi-platform builds (Linux, Windows, macOS)
-
Release: Automatically creates releases
- Latest Development Builds: Created on every push to main branch as pre-release
- Stable Releases: Created when version tags (v*..) are pushed
- Multi-platform binaries included in all releases
-
Security: Weekly security audits and checks on main branch
Release Types
-
Development Releases (automatic):
- Triggered by pushes to main branch
- Tagged as "latest" (replaces previous latest)
- Marked as pre-release
- Contains binaries for Linux x86_64, Windows x86_64, macOS x86_64
-
Stable Releases (manual):
- Triggered by pushing version tags (e.g.,
git tag v1.0.0 && git push origin v1.0.0
) - Tagged with the version number
- Not marked as pre-release
- Contains binaries for all platforms
- Triggered by pushing version tags (e.g.,
Security Considerations
- Password Strength: Use strong, unique passwords
- Key Storage: Passwords are not stored; enter each time
- Temp Files: No temporary files created during encryption
- Memory: Sensitive data is zeroized after use
- Verification: Always verify decrypted data integrity
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.