A Python tool for adding password protection to PDF files. This tool allows you to encrypt PDF documents with a password to secure sensitive information.
- Password Encryption: Add password protection to PDF files
- Metadata Preservation: Maintains original PDF structure and metadata
- Error Handling: Comprehensive error handling for various scenarios
- Simple Interface: Easy-to-use command-line interface
- Python 3.7+
- PyPDF2 library
# Install required packages
pip install PyPDF2
# Or on Kali Linux
sudo apt install python3-pypdf2# Download the tool
git clone https://github.com/Sergios9494/pdf-protection-tool.git
cd pdf-protection-tool
# Make executable
chmod +x ProtectionPDF_Tool.py# Protect a PDF with password
python3 ProtectionPDF_Tool.py input.pdf output_protected.pdf mypasswordpython3 ProtectionPDF_Tool.py <input_pdf> <output_pdf> <password>
Parameters:
input_pdf: Path to the original PDF fileoutput_pdf: Path for the password-protected PDF filepassword: Password to protect the PDF
python3 ProtectionPDF_Tool.py document.pdf secure_document.pdf secret123Output:
Password-protected PDF saved as secure_document.pdf
# Protect financial report
python3 ProtectionPDF_Tool.py financial_report.pdf financial_report_secure.pdf finance2024
# Protect confidential document
python3 ProtectionPDF_Tool.py confidential.pdf confidential_secure.pdf topsecretThe tool handles various error scenarios:
- File Not Found: If the input PDF doesn't exist
- Invalid PDF: If the file is not a valid PDF
- Permission Errors: If there are file access issues
- General Errors: Catches and reports other exceptions
- Legitimate document protection
- Personal file security
- Business document encryption
- Educational purposes
- Use strong passwords (at least 12 characters)
- Include uppercase, lowercase, numbers, and symbols
- Store passwords securely
- Test password protection before sharing files
Module Not Found
pip install PyPDF2
# or
sudo apt install python3-pypdf2Permission Denied
chmod +x ProtectionPDF_Tool.pyFile Not Found
- Check file path and spelling
- Ensure file exists in the specified location
- Use absolute paths if needed
Invalid PDF Error
- Verify the file is a valid PDF
- Check if the PDF is corrupted
- Try opening the PDF in a PDF viewer first
- Protect personal documents
- Secure financial records
- Encrypt sensitive photos/scans
- Protect confidential reports
- Secure client documents
- Encrypt internal communications
- Learn PDF security concepts
- Understand encryption principles
- Practice Python file handling
- PyPDF2: Python library for PDF manipulation
- Standard Library: sys module for command-line arguments
- Reads PDF files in binary mode
- Preserves all pages and content
- Applies encryption using PyPDF2's encrypt method
- Writes protected PDF in binary mode
Contributions are welcome! Please feel free to submit:
- Bug reports
- Feature requests
- Code improvements
- Documentation updates
This project is licensed under the MIT License.
Sergios9494 - Cybersecurity Professional
- GitHub: @Sergios9494
- Built for document security needs
- Designed for educational and professional use
- Inspired by cybersecurity best practices
Secure Your Documents! 🔒