ByteLock is a high-performance, multi-process file encryption and decryption tool written in C++. By leveraging both multiprocessing and multithreading, the project aims to enhance the efficiency and performance of cryptographic operations. It recursively processes all files in a user-specified directory, encrypting or decrypting them in parallel using a shared memory queue and semaphores for inter-process communication. The encryption key is securely read from a .env file. ByteLock is designed for speed, reliability, and ease of use, making it ideal for bulk file security operations.
- Recursive Directory Processing: Encrypts or decrypts all files in a given directory and its subdirectories.
- Parallel Processing: Utilizes multiple processes to handle files concurrently for maximum speed.
- Shared Memory Queue: Efficient task management using shared memory and POSIX semaphores.
- Customizable Key: Reads encryption/decryption key from a
.envfile for flexible security. - Robust Error Handling: Gracefully manages file and system errors.
- Cross-Platform Build: Simple compilation using a Makefile.
- Process Management: Implements process creation and management using fork().
- Task Queue: Manages encryption and decryption tasks using a queue structure.
- Task Execution: Child processes execute tasks independently, allowing parallel processing.
- Clone the repository:
git clone <repo-url> cd ByteLock
- Set up the encryption key:
- Create a
.envfile in the root directory containing a single integer (the key), e.g.:42
- Create a
- Build the project:
make
- (Optional) Generate test files:
python3 makeDirs.py
- Run the main program:
./encrypt_decrypt
- Follow the prompts:
- Enter the directory path to process.
- Enter the action:
encryptordecrypt.
All files in the directory (and subdirectories) will be processed in parallel.
- C++17
- POSIX APIs: Shared memory, semaphores, process management
- Standard C++ Libraries:
<filesystem>,<fstream>,<mutex>, etc. - Makefile for build automation
- Python (for test file generation)
- User Input:
- The user specifies the target directory and the action (encrypt/decrypt).
- Directory Traversal:
- The system recursively scans all files in the specified directory.
- Task Creation:
- For each file, a task is created (either encryption or decryption) and added to a shared memory queue.
- Parallel Processing:
- Each task is picked up by a separate process (using
fork()), allowing multiple files to be processed simultaneously.
- Each task is picked up by a separate process (using
- Encryption/Decryption:
- Each process reads the encryption key from the
.envfile and performs the operation on its assigned file.
- Each process reads the encryption key from the
- Completion:
- The system waits for all child processes to finish, ensuring all files are processed.
- Input Layer: User prompt for directory and action.
- Task Queue: Shared memory structure holding pending tasks.
- Process Pool: Multiple processes spawned to handle tasks in parallel.
- File Handler: Each process opens, reads, and writes to files as needed.
- Key Management: Reads the key from
.envfor each operation. - Synchronization: Semaphores ensure safe access to the shared queue.
- Fork the repository and create a feature branch.
- Write clear, concise commit messages.
- Ensure code is well-documented and formatted.
- Submit a pull request with a detailed description of your changes.
