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
-
Clone the repository:
git clone https://github.com/john0isaac/protect-my-dir.git cd protect-my-dir
-
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:
--directoryor-dir: Specify the directory containing files to encrypt or decrypt.--encryptor-e: Encrypt the files in the specified directory.--decryptor-d: Decrypts all.encfiles in the specified directory.
How It Works
-
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
.encextension. - The original file is securely deleted.
-
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.
Metadata
Release files for protect-my-dir 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| protect_my_dir-0.1.1.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| protect_my_dir-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.2 kB
Release files / protect_my_dir-0.1.1.tar.gz
| Download URL | protect_my_dir-0.1.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f67cce8d2ddf0d645c341e25bc6761aea943a188897606e370dc3f6ec3854907
|
|
BLAKE2b-256 checksum How to use checksums |
bbe513079dc40d6886930862c2906a05ea2252d36a070c1096d411894e110893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Release files / protect_my_dir-0.1.1-py3-none-any.whl
| Download URL | protect_my_dir-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b7c5c61b007eb078967a6e7f15cb13e4f6c51b491da902e12d11727af39efbc
|
|
BLAKE2b-256 checksum How to use checksums |
3b985cc5998a9a4dcb630c8b89889149ab5757790d662c50675fab9dca4f95aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|