Intelligent file compression with military-grade encryption and blockchain verification
A production-ready compression system combining AI-powered compression, AES-256-GCM encryption, IPFS storage, and blockchain verification for secure, efficient file management.
LandGuard is an advanced file compression and storage system that:
- 🤖 Compresses files using intelligent algorithms (Huffman, VAE)
- 🔒 Encrypts with military-grade AES-256-GCM encryption
- 🌐 Stores on decentralized IPFS network via Pinata
- ⛓️ Verifies on Polygon blockchain for tamper-proof records
- 📦 Packages in custom
.ppccontainer format
Perfect for secure document storage, data archiving, and decentralized file sharing!
| Feature | Description |
|---|---|
| 🤖 AI-Powered Compression | Intelligent compression with automatic fallback |
| 🔐 Military-Grade Encryption | AES-256-GCM with PBKDF2 key derivation |
| 🌐 IPFS Decentralized Storage | Permanent storage via Pinata gateway |
| 📦 Custom .ppc Format | Metadata-rich container format |
| 🎯 Smart File Detection | Automatic MIME type and category recognition |
| 💻 Modern CLI Interface | Easy-to-use command line tool |
Try It Out : https://landguard-681c.onrender.com/
Before installing, make sure you have:
- Python 3.8+ installed (Download here)
- Git installed (Download here)
- Basic command line knowledge
# Clone the repository
git clone https://github.com/Shivanikinagi/LandGuard.git
cd LandGuard
# Configure environment
cp .env.example .env
# Edit .env with your Pinata JWT token
# Start all services
docker-compose up -dStep 1: Clone the Repository
git clone https://github.com/Shivanikinagi/LandGuard.git
cd LandGuard**Step 2: Navigate to the PCC Directory
cd pccpython -m venv venvOn Windows (PowerShell):
.\venv\Scripts\Activate.ps1On Windows (Command Prompt):
.\venv\Scripts\activate.batOn Linux/Mac:
source venv/bin/activatepip install typer cbor2 cryptography requests richpython main.py --helpYou should see the help menu with available commands!
Step 1: Create a test file
echo "Hello, Pied Piper!" > test.txtStep 2: Compress and encrypt it
python main.py pack test.txt --password mySecurePassword123What happens:
- ✅ File is compressed
- ✅ Encrypted with your password
- ✅ Uploaded to IPFS
- ✅ Saved as
test.txt.ppc
Expected Output:
✅ Packing: test.txt
📊 Read 20 bytes
🔍 Detected: text (text/plain)
📦 Compressed with: huffman → 15 bytes
🔒 Encrypted with AES-256-GCM
💾 Created: test.txt.ppc
📈 Compression Ratio: 1.33x (25% smaller)
🌐 IPFS Link: https://gateway.pinata.cloud/ipfs/Qm...
Restore the original file:
python main.py unpack test.txt.ppc --password mySecurePassword123What happens:
- ✅ File is decrypted with your password
- ✅ Decompressed to original format
- ✅ Saved as
restored_test.txt
Expected Output:
🔓 Unpacking: test.txt.ppc
🔑 Decrypted successfully
📤 Decompressed: 15 → 20 bytes
💾 Restored: restored_test.txt
Check metadata without extracting:
python main.py info test.txt.ppcOutput shows:
- Original filename and size
- Compression algorithm used
- Compression ratio achieved
- Encryption details
- File type information
| Command | Purpose | Usage |
|---|---|---|
pack |
Compress, encrypt & upload file | python main.py pack <file> -p <password> |
unpack |
Decrypt & decompress file | python main.py unpack <file.ppc> -p <password> |
info |
Display file metadata | python main.py info <file.ppc> |
Pack Command:
python main.py pack <input_file> --password <your_password><input_file>: Path to the file you want to compress--passwordor-p: Password for encryption (required)
Unpack Command:
python main.py unpack <ppc_file> --password <your_password> [--output <output_path>]<ppc_file>: Path to the .ppc file--passwordor-p: Password used during compression--outputor-o: (Optional) Custom output filename
Info Command:
python main.py info <ppc_file>- No password needed - only reads metadata
| Feature | Specification |
|---|---|
| Algorithm | AES-256-GCM (Galois/Counter Mode) |
| Key Derivation | PBKDF2-HMAC-SHA256 |
| Iterations | 100,000 (slows down brute-force attacks) |
| Salt | 16-byte random per file |
| IV | 12-byte random per file |
| Authentication | Built-in authentication tag |
✅ Military-Grade Encryption - Same standard used by governments
✅ Unique Salt Per File - Prevents rainbow table attacks
✅ Authentication Tag - Detects tampering attempts
✅ No Password Storage - Password never saved anywhere
✅ Key Stretching - PBKDF2 makes cracking extremely slow
✅ Immutable Records - All documents registered on Polygon Mumbai testnet
✅ Transparent Verification - Transactions visible on PolygonScan Explorer
✅ Decentralized Storage - IPFS ensures permanent document availability
✅ Tamper-Evident - Any modification breaks the cryptographic chain
IPFS (InterPlanetary File System) is a decentralized storage network that:
- 🌍 Stores files across multiple nodes worldwide
- 🔗 Provides permanent content-addressed links
- 🚀 Enables fast peer-to-peer file sharing
- 💪 Resists censorship and single points of failure
- Upload: Your encrypted
.ppcfile is uploaded to Pinata's IPFS gateway - CID Generation: Receives unique Content Identifier (CID)
- Global Access: Anyone with the link can download your file
- Permanent Storage: File remains accessible as long as it's pinned
https://gateway.pinata.cloud/ipfs/QmXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Note: Files are encrypted before upload, so only those with your password can decrypt them!
.ppc files are custom containers created by Pied Piper that bundle:
- 📋 Metadata (file info, compression details)
- 🔒 Encrypted Data (your compressed content)
┌─────────────────────────────────────┐
│ Header (4 bytes) │ ← Size of metadata
├─────────────────────────────────────┤
│ Metadata (JSON) │ ← File information
├─────────────────────────────────────┤
│ Encrypted Compressed Data │ ← Your protected content
└─────────────────────────────────────┘
{
"original_filename": "document.pdf",
"original_mime_type": "application/pdf",
"file_type": "document",
"model_used": "huffman",
"original_size_bytes": 1048576,
"compressed_size_bytes": 524288,
"compression_ratio": 2.0,
"encryption_algo": "AES-256-GCM",
"created_at": "2025-11-24T10:30:00Z"
}Why This Matters:
- ✅ Self-documenting files
- ✅ Easy to verify compression effectiveness
- ✅ Tracks which algorithm was used
- ✅ Preserves original file information
Pied Piper 2.0 intelligently handles various file types:
| Category | File Extensions | Compression Method |
|---|---|---|
| 📝 Text | .txt, .md, .rtf, .log, .csv |
Huffman Coding |
| 🖼️ Images | .jpg, .png, .gif, .bmp, .webp |
VAE (Neural Network) |
| 🎵 Audio | .mp3, .wav, .flac, .aac, .ogg |
Placeholder (Coming Soon) |
| 🎥 Video | .mp4, .mkv, .avi, .mov, .webm |
Placeholder (Coming Soon) |
| 📄 Documents | .pdf, .docx, .xlsx, .pptx |
Smart Detection |
| 🗜️ Archives | .zip, .rar, .7z, .tar, .gz |
Pass-through |
| 📊 Data | .json, .xml, .yaml, .sql |
Huffman Coding |
| 💻 Code | .py, .java, .js, .cpp, .html |
Huffman Coding |
Note: If AI compression fails or is unavailable, the system automatically falls back to standard compression methods!
┌──────────────┐
│ Input File │
└──────┬───────┘
│
▼
┌─────────────────────┐
│ 🔍 File Type │ Detect MIME type and category
│ Detection │
└──────┬──────────────┘
│
▼
┌─────────────────────┐
│ 🤖 AI Compression │ Apply intelligent compression
│ │ (Huffman, VAE, etc.)
└──────┬──────────────┘
│
▼
┌─────────────────────┐
│ 🔒 AES Encryption │ Encrypt with your password
│ │
└──────┬──────────────┘
│
▼
┌─────────────────────┐
│ 📦 PPC Packaging │ Create .ppc container
│ │
└──────┬──────────────┘
│
▼
┌─────────────────────┐
│ 🌐 IPFS Upload │ Upload to decentralized network
│ │
└──────┬──────────────┘
│
▼
┌──────────────────┐
│ 🎉 Done! │ File compressed, encrypted & uploaded
└──────────────────┘
.ppc File → Decrypt → Decompress → Restore Original File
# Compress and encrypt a confidential document
python main.py pack confidential.pdf -p MyStr0ngP@ssw0rd
# Share the IPFS link with authorized users
# They can download and decrypt with the password
python main.py unpack confidential.pdf.ppc -p MyStr0ngP@ssw0rd# Compress multiple files with the same password
python main.py pack report1.txt -p project2024
python main.py pack report2.txt -p project2024
python main.py pack report3.txt -p project2024# Backup your source code securely
python main.py pack main.py -p backup123
python main.py pack config.json -p backup123
# Later, restore them
python main.py unpack main.py.ppc -p backup123
python main.py unpack config.json.ppc -p backup123# View metadata without extracting
python main.py info document.pdf.ppc
# Check compression effectiveness
# Look for "compression_ratio" in the output✅ DO:
- Use strong passwords (12+ characters)
- Mix uppercase, lowercase, numbers, symbols
- Use unique passwords for important files
- Store passwords in a password manager
❌ DON'T:
- Use common words or phrases
- Reuse passwords from other services
- Share passwords over insecure channels
- Forget your password (files cannot be recovered!)
✅ DO:
- Keep original files until you verify .ppc extraction works
- Test decompression immediately after compression
- Store IPFS links in a safe place
- Use descriptive filenames
❌ DON'T:
- Delete original files without testing
- Compress already compressed files (ZIP, RAR, etc.)
- Use very weak passwords for sensitive data
💡 Large Files: Processing may take longer (1-2 minutes for 100MB+)
💡 Already Compressed: ZIP, PNG, MP4 won't compress much further
💡 Text Files: Achieve best compression ratios (up to 50-70%)
💡 Network Speed: IPFS upload speed depends on your internet connection
pcc/
├── main.py # 🎯 CLI entry point and command handlers
├── cli/
│ └── main.py # 💻 Interactive menu interface
├── core/
│ └── ppc_format.py # 📦 PPC container format logic
├── detector/
│ └── file_type.py # 🔍 MIME type and category detection
├── crypto/
│ └── aes.py # 🔒 AES-256-GCM encryption/decryption
├── storage/
│ └── ipfs_client.py # 🌐 IPFS upload via Pinata
├── models/
│ ├── registry.py # 🗂️ Model selection system
│ ├── text_huffman.py # 📝 Huffman compression for text
│ ├── image_vae.py # 🖼️ VAE compression for images
│ └── base.py # 🏗️ Base compression interface
└── compressors/
├── image/
│ ├── train_vae.py # 🎓 VAE model training
│ └── vae.py # 🧠 Neural network architecture
└── text/
└── bpe_compressor.py # 📊 Byte Pair Encoding
-
CLI Layer (
main.py,cli/main.py)- Handles user input and commands
- Provides interactive menu interface
- Displays progress and results
-
Detection Layer (
detector/)- Identifies file MIME type
- Categorizes file (text, image, video, etc.)
- Selects appropriate compression model
-
Compression Layer (
models/,compressors/)- Applies AI-powered compression
- Falls back to standard algorithms if needed
- Tracks compression ratios
-
Security Layer (
crypto/)- Generates secure encryption keys from passwords
- Encrypts compressed data with AES-256-GCM
- Adds authentication tags
-
Packaging Layer (
core/)- Creates .ppc container format
- Embeds metadata (file info, compression stats)
- Ensures cross-platform compatibility
-
Storage Layer (
storage/)- Uploads to IPFS via Pinata gateway
- Returns permanent content-addressed links
- Handles upload failures gracefully
The system has multiple fallback layers to ensure reliability:
AI Compression Attempt
↓
[Success?] ─Yes→ Use AI-compressed data
↓
No
↓
Standard Compression (Zstd/Brotli)
↓
[Success?] ─Yes→ Use standard-compressed data
↓
No
↓
Store Original Data (no compression)
This ensures:
- ✅ No file corruption or data loss
- ✅ System works even if AI models unavailable
- ✅ Graceful degradation of features
- ✅ Always produces valid .ppc files
How it works:
- Analyzes character frequency in your text
- Assigns shorter codes to common characters
- Assigns longer codes to rare characters
- Achieves 30-50% size reduction for typical text
Best for: .txt, .md, .log, .csv, .json, .xml, code files
Example:
Original: "AAABBC" (48 bits with 8-bit encoding)
Huffman: A=0, B=10, C=11 → "00010101011" (11 bits)
Savings: 77% compression!
How it works:
- Neural network trained on 13,420 CIFAR-10 images
- Encodes images into compact latent space representation
- Learns to preserve important visual features
- Achieves lossy compression with quality control
Best for: .jpg, .png, .bmp, .gif (photos and graphics)
Example:
Original: 256×256 RGB image (196,608 bytes)
VAE: Compressed latent vector (~2,000 bytes)
Savings: 98% compression with acceptable quality
Planned implementation:
- Neural Video Codec (NVC)
- Frame-by-frame VAE encoding
- Temporal compression between frames
- Target: 50-70% size reduction vs H.264
| Feature | Status | Notes |
|---|---|---|
| CLI Interface | ✅ Complete | Typer-based with rich output |
| File Type Detection | ✅ Complete | MIME type and category detection |
| AES-256-GCM Encryption | ✅ Complete | Military-grade security |
| PPC Container Format | ✅ Complete | Metadata-rich packaging |
| IPFS Integration | ✅ Complete | Pinata gateway upload |
| Huffman Text Compression | ✅ Complete | 30-50% text compression |
| VAE Image Compression | Model trained, debugging in progress | |
| Error Handling | ✅ Complete | Comprehensive fallback system |
| Feature | Status | Target |
|---|---|---|
| Video Compression | 🔄 Planned | Neural Video Codec |
| Audio Compression | 🔄 Planned | Wavelet-based compression |
| Image Decompression Fix | 🐛 Debugging | Resolve 0-byte output issue |
| Batch Processing | 📋 Planned | Process multiple files at once |
| Progress Bars | 📋 Planned | Visual feedback for large files |
| Web Interface | 💡 Future | Browser-based UI |
- Custom model training interface
- Compression quality presets (fast/balanced/maximum)
- Deduplication for similar files
- Compression statistics dashboard
- API for programmatic access
- Docker containerization
- Cloud deployment options
Problem: Python can't find required packages
Solution:
# Make sure virtual environment is activated
.\venv\Scripts\Activate.ps1 # Windows
source venv/bin/activate # Linux/Mac
# Reinstall dependencies
pip install -r requirements.txtProblem: Wrong password or corrupted file
Solution:
- ✅ Verify you're using the correct password (case-sensitive!)
- ✅ Check if the .ppc file is corrupted (try downloading again)
- ✅ Ensure file wasn't modified after creation
Problem: Network issues or Pinata service unavailable
Solution:
- ✅ Check your internet connection
- ✅ File is still saved locally (in same folder as input)
- ✅ You can manually upload the .ppc file to IPFS later
Problem: File doesn't compress well (ratio close to 1.0)
Solution:
- This is normal for already-compressed files (ZIP, MP4, PNG)
- These formats are already optimized
- Encryption still protects your data
Problem: "SyntaxError" or compatibility issues
Solution:
# Check your Python version
python --version
# Should be 3.8 or higher
# If not, upgrade Python and recreate virtual environmentWe welcome contributions! Here's how you can help:
-
Report Bugs 🐛
- Open an issue on GitHub
- Include error messages and steps to reproduce
-
Suggest Features 💡
- Share ideas for new compression algorithms
- Propose UI/UX improvements
-
Submit Code 💻
- Fork the repository
- Create a feature branch
- Submit a pull request
-
Improve Documentation 📚
- Fix typos or unclear instructions
- Add examples and tutorials
- Translate documentation
# Clone repository
git clone https://github.com/Parthkk90/compression-.git
cd compression-/pcc
# Install development dependencies
pip install -r requirements.txt
pip install pytest black flake8
# Run tests
pytest tests/
# Format code
black .- 🐛 Bug Reports: GitHub Issues
- 💬 Questions: GitHub Discussions
- 🌐 Documentation: QUICK_START.md | USAGE.md
This project is licensed under the MIT License - see the LICENSE file for details.
What this means:
- ✅ Free to use for personal and commercial projects
- ✅ Modify and distribute as you wish
- ✅ No warranty provided (use at your own risk)
Special thanks to:
- OpenAI - For GPT and compression research inspiration
- IPFS Community - For decentralized storage technology
- Pinata - For IPFS gateway services
- PyTorch Team - For deep learning framework
- Typer - For excellent CLI framework
- Huffman, D. A. (1952). "A Method for the Construction of Minimum-Redundancy Codes"
- Kingma, D. P., & Welling, M. (2014). "Auto-Encoding Variational Bayes"
- Ballé, J., et al. (2018). "Variational Image Compression with a Scale Hyperprior"
- ✅ Core compression system
- ✅ AES encryption integration
- ✅ IPFS storage support
- ✅ CLI interface
- 🔄 Fix image decompression bug
- 🔄 Implement video compression
- 🔄 Add audio compression
- 🔄 Web interface prototype
The recommended way to deploy LandGuard is using Docker:
# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downServices:
- PCC: Compression service on port 8000
- LandGuard: Agent orchestration on port 8001
- API: REST API interface
- Nginx: Reverse proxy (production)
For production deployment, see QUICK_START.md and USAGE.md.
- Core compression system (Huffman, VAE)
- AES-256-GCM encryption
- IPFS integration via Pinata
- Blockchain verification on Polygon
- CLI and API interfaces
- Docker deployment
- Image decompression optimization
- Enhanced error handling
- Performance improvements
- Video/audio compression
- Batch processing
- Web interface
- Cloud deployment templates
- Mobile app