A simple Python tool to encrypt and decrypt PDF files in batch.
- Encrypt PDF files with AES-256-R5 encryption
- Decrypt password-protected PDF files
- Batch process multiple PDF files from a directory
- Configure settings via command-line arguments or JSON config file
- Optional: Automatically move processed files to a completed directory
- Python 3.x
- pypdf library
- Clone this repository:
git clone https://github.com/queenie-lee/Encrypt-PDF.git
cd Encrypt-PDF- Install dependencies:
pip install -r requirements.txtEncrypt PDFs:
python main.py encrypt -s /path/to/source -d /path/to/destination -p yourpasswordDecrypt PDFs:
python main.py decrypt -s /path/to/source -d /path/to/destination -p yourpasswordWith completed directory (optional):
python main.py encrypt -s /path/to/source -d /path/to/destination -p yourpassword -c /path/to/completedCreate a config.json file with your settings:
{
"source": "files/input",
"destination": "files/output",
"completed": "files/completed",
"password": "yourpassword"
}Then run:
python main.py encrypt -f config.jsonor
python main.py decrypt -f config.jsonmode(required):encryptordecrypt-f, --file: Path to JSON config file-s, --source: Source directory containing PDF files-d, --destination: Destination directory for processed files-p, --password: Password for encryption/decryption-c, --completed: Directory to move source files after processing (optional)
Note: Command-line arguments override config file settings.
Example 1: Encrypt all PDFs in a folder
python main.py encrypt -s ./documents -d ./encrypted -p MySecurePass123Example 2: Decrypt PDFs and archive originals
python main.py decrypt -s ./encrypted -d ./decrypted -p MySecurePass123 -c ./archiveExample 3: Use config file for encryption
python main.py encrypt -f config.jsonSee LICENSE file for details.