Skip to content

Markkreel/Encryption-CLI

Repository files navigation

Encryption CLI

A Python utility for securely encrypting files with AES-256 encryption and zlib compression, with integrity verification and progress tracking.

Features

  • 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

Specifications

  • AES-256 CBC mode encryption
  • Zlib compression with configurable levels (1-9)
  • SHA-256 hash verification for tamper detection

Installation

# Requires Python 3.9+
pip install -r requirements.txt

Usage

Secure a File (Encrypt + Compress)

from src.main import secure_file

secure_file(
    "sensitive.docx",
    "your_strong_password",
    compression_level=7  # Optimal balance of speed/size
)
# Creates: sensitive.docx.flc

Encrypt Command

python src/cli.py encrypt file_path --password yourpassword --compression balanced

Available compression levels: none, fast, balanced, max

Restore a File (Decrypt + Decompress)

from src.main import restore_file

restore_file(
    "sensitive.docx.flc",
    "your_strong_password"
)
# Restores: sensitive.docx

Decrypt Command

python src/cli.py decrypt file_path --password mypassword

Optional 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

Technical Details

File Structure (.flc)

[1 byte: compression level] +
[32 bytes: SHA-256 hash] +
[zlib compressed data] +
[AES-256 encrypted payload]

Integrity Verification

  1. Generates SHA-256 hash of original data
  2. Stores hash in file header
  3. Verifies hash during restoration

Testing

Running Tests Locally

Run test suite:

pytest tests/ -v

Running Tests with Docker

You 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-tests

Or using Docker Compose:

docker-compose up

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Submit pull request

License

MIT License - See LICENSE for details

Last Updated: 30-05-2025 ⸺ Last Reviewed: 13-07-2025

About

A Python CLI tool that encrypts files with AES-256 and verifies integrity using SHA-256, offering a simple, secure way to protect sensitive data.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors