Skip to main content

Simple python project to encrypt files and require a password to access them.

Project description

Protect My Dir

A command-line tool designed to encrypt and decrypt files within a directory using a password. It provides a simple and secure way to protect sensitive files using AES encryption.

Features

  • AES Encryption: Uses AES (Advanced Encryption Standard) in CBC (Cipher Block Chaining) mode with PKCS7 padding for secure encryption.
  • Password-Based Key Derivation: Utilizes PBKDF2 with SHA256 for deriving encryption keys from passwords, ensuring strong security.
  • Salt and IV Generation: Automatically generates a unique salt and initialization vector (IV) for each file to enhance security.
  • File Encryption: Encrypts individual files and removes the original unencrypted files.
  • File Decryption: Decrypts previously encrypted files and restores them to their original state.
  • Directory Support: Recursively encrypts or decrypts all files in a specified directory.
  • Error Handling: Provides meaningful error messages for incorrect passwords or corrupted files.
  • Cross-Platform: Works on any platform that supports Python.

Installation

  1. Clone the repository:

     git clone https://github.com/john0isaac/protect-my-dir.git
     cd protect-my-dir
    
  2. Create a virtual environment and Install the required dependencies using uv:

    uv sync
    

Usage

The tool provides a CLI interface for encrypting and decrypting directories. Below are the available commands and options:

  • Encrypt a Directory:

    To encrypt all files in a directory:

    protect-my-dir --directory /path/to/directory --encrypt
    

    You will be prompted to enter a password. The tool will encrypt all files in the directory and remove the original files.

  • Decrypt a Directory:

    To decrypt all files in a directory:

    protect-my-dir --directory /path/to/directory --decrypt
    

    You will be prompted to enter the password used for encryption. The tool will decrypt all files in the directory and restore them to their original state.

Command-line options:

  • --directory or -dir: Specify the directory containing files to encrypt or decrypt.
  • --encrypt or -e: Encrypt the files in the specified directory.
  • --decrypt or -d: Decrypts all .enc files in the specified directory.

How It Works

  1. Encryption:

    • A unique salt and IV are generated for each file.
    • The password is used to derive a 256-bit encryption key using PBKDF2.
    • The file is padded, encrypted, and saved with a .enc extension.
    • The original file is securely deleted.
  2. Decryption:

    • The salt and IV are extracted from the encrypted file.
    • The password is used to derive the decryption key.
    • The file is decrypted, unpadded, and restored to its original state.
    • The encrypted file is securely deleted.

Security Considerations

  • Password Strength: Use a strong, unique password to ensure the security of your files.
  • Backup: Always keep a backup of your password. If you lose it, the files cannot be decrypted.
  • File Removal: The tool deletes original files after encryption and encrypted files after decryption. Ensure you have backups if needed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protect_my_dir-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protect_my_dir-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file protect_my_dir-0.1.0.tar.gz.

File metadata

  • Download URL: protect_my_dir-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for protect_my_dir-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77cec88d29dae1945684cd94881f8aaab1a0510150075ee8b57d8ac08a4f245d
MD5 392f4067aba5215ba4e072da470a35c8
BLAKE2b-256 5d948566f1a5421649b7b66b71b1cf9ea886e69049c105fbbb7da5c1cd3beb4d

See more details on using hashes here.

File details

Details for the file protect_my_dir-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: protect_my_dir-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for protect_my_dir-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 652b0b5a45773f713bcb4a39ed3060bdb9533fc1661de212fe26ae5b0a3228f1
MD5 bf86bd4aa71ce3602257462bce29ba22
BLAKE2b-256 070607b5638d8a046c78b50d0670b4c340c219e75e147401f6b4f2fc54c356ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page