A Python utility for securely encrypting files with AES-256 encryption and zlib compression, with integrity verification and progress tracking.
- Complete CLI integration for encryption, decryption, and compression
- Configurable compression levels through CLI arguments
- Extensive logging and error handling
- Support for multiple file formats
- Progress tracking during operations
- AES-256 CBC mode encryption
- Zlib compression with configurable levels (1-9)
- SHA-256 hash verification for tamper detection
# Requires Python 3.9+
pip install -r requirements.txtfrom src.main import secure_file
secure_file(
"sensitive.docx",
"your_strong_password",
compression_level=7 # Optimal balance of speed/size
)
# Creates: sensitive.docx.flcpython src/cli.py encrypt file_path --password yourpassword --compression balancedAvailable compression levels: none, fast, balanced, max
from src.main import restore_file
restore_file(
"sensitive.docx.flc",
"your_strong_password"
)
# Restores: sensitive.docxpython src/cli.py decrypt file_path --password mypasswordOptional arguments:
--output: Specify custom output path
For more example commands and usage scenarios, refer to the CLI_EXAMPLES.md document or the sample.sh script included in the repository. The script includes examples of:
- Direct file compression with different compression levels
- Progress tracking during compression/decompression
- Various compression configurations
- Basic and advanced usage patterns
[1 byte: compression level] +
[32 bytes: SHA-256 hash] +
[zlib compressed data] +
[AES-256 encrypted payload]- Generates SHA-256 hash of original data
- Stores hash in file header
- Verifies hash during restoration
Run test suite:
pytest tests/ -vYou can also run tests using Docker:
# Build the Docker image
docker build -t filelock-tests .
# Run tests in a Docker container
docker run --rm filelock-testsOr using Docker Compose:
docker-compose up- Fork the repository
- Create feature branch
- Submit pull request
MIT License - See LICENSE for details
Last Updated: 30-05-2025 ⸺ Last Reviewed: 13-07-2025