A secure file encryption tool with password protection, supporting both command-line and terminal user interface modes.
- 🔐 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
git clone https://github.com/npv2k1/sf-cli.git
cd sf-cli
cargo build --releaseDownload 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
# Show help
./sf-cli --help
# Encrypt a file with password prompt
./sf-cli encrypt secret.txt
# Encrypt with compression and custom output
./sf-cli encrypt data.txt -c -o data.sf.gz
# Encrypt with password from command line (not recommended for production)
./sf-cli encrypt file.txt -p mypassword
# Decrypt a file
./sf-cli decrypt secret.sf
# Decrypt with compression
./sf-cli decrypt data.sf.gz -c
# Encrypt an entire directory
./sf-cli encrypt my_folder/
# Decrypt a directory
./sf-cli decrypt my_folder.sfWatch mode monitors directories for file changes and automatically processes them:
# Watch directory and auto-encrypt new files
./sf-cli watch-encrypt /path/to/source --password mypass
# Watch with target directory and delete source files
./sf-cli watch-encrypt /path/to/source -t /path/to/encrypted -d --password mypass
# Watch with file extension filtering (only .txt and .doc files)
./sf-cli watch-encrypt /path/to/source -e "txt,doc" --password mypass
# Process existing files on startup
./sf-cli watch-encrypt /path/to/source --process-existing --password mypass
# Watch directory and auto-decrypt encrypted files
./sf-cli watch-decrypt /path/to/encrypted -t /path/to/decrypted --password mypass
# Watch decrypt with compression and delete source
./sf-cli watch-decrypt /path/to/encrypted -c -d --password mypass- 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
Start the interactive mode:
./sf-cli tui
# or simply
./sf-cli1- Encrypt file/directory2- Decrypt file/directoryEnter- Confirm inputEsc- Return to main menuq- Quit application
- 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
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
- Algorithm: gzip compression
- When Applied: Before encryption for maximum security
- Benefits: Significant space savings for repetitive data
# Create a test file
echo "This is sensitive data" > secret.txt
# Encrypt it
./sf-cli encrypt secret.txt
# Output: ✓ Encrypt secret.txt -> secret.sf (83 bytes)
# Decrypt it
./sf-cli decrypt secret.sf
# Output: ✓ Decrypt secret.sf -> secret (23 bytes)# Setup watch directories
mkdir -p /tmp/documents /tmp/encrypted /tmp/decrypted
# Start watching for new documents to encrypt
./sf-cli watch-encrypt /tmp/documents -t /tmp/encrypted -p mypassword &
# Add files to watch - they will be automatically encrypted
echo "Confidential report" > /tmp/documents/report.txt
echo "Meeting notes" > /tmp/documents/notes.txt
# Files automatically encrypted to /tmp/encrypted/
# Start watching encrypted directory for auto-decryption
./sf-cli watch-decrypt /tmp/encrypted -t /tmp/decrypted -p mypassword &
# Any new .sf files in /tmp/encrypted will be auto-decrypted to /tmp/decrypted/# Watch only specific file types and delete originals
./sf-cli watch-encrypt /home/user/documents \
--target-dir /backup/encrypted \
--extensions "txt,doc,pdf" \
--delete-source \
--process-existing \
--password mypassword
# Watch with compression
./sf-cli watch-encrypt /data/logs \
--compress \
--delete-source \
--password logpass# Create a large repetitive file
python3 -c "print('repeated data ' * 10000)" > large.txt
# Encrypt with compression
./sf-cli encrypt large.txt -c
# Achieves 95%+ compression ratio on repetitive data# Create a directory with files
mkdir my_docs
echo "Document 1" > my_docs/doc1.txt
echo "Document 2" > my_docs/doc2.txt
# Encrypt the entire directory
./sf-cli encrypt my_docs/
# Output: ✓ Encrypt my_docs -> my_docs.sf (218 bytes, compressed)
# Decrypt the directory
./sf-cli decrypt my_docs.sf
# Restores the complete directory structure- 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
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
- Rust 1.70 or later
cargo buildcargo testcargo run --example basic_usagecargo clippy -- -D warningscargo fmtSF-CLI includes an automated version management script for releasing new versions:
# Increment patch version (1.0.4 → 1.0.5)
./scripts/version.sh patch
# Increment minor version (1.0.4 → 1.1.0)
./scripts/version.sh minor
# Increment major version (1.0.4 → 2.0.0)
./scripts/version.sh major
# Test without making changes
./scripts/version.sh patch --dry-runThe script automatically:
- Updates
Cargo.tomlversion - 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.
This project uses GitHub Actions for continuous integration and deployment:
-
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
-
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.,
- 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
- Hybrid Encryption: When using hybrid encryption, prefer ECDSA (P-256) keys over RSA keys for better security
For known security advisories and mitigation strategies, see SECURITY.md.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
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.