> COMPRESSION CIPHER
The idea in plain English: You know how .zip files make folders smaller? This cipher does the same thing — it takes a message, compresses it (like zipping a file), then presents the compressed data as a hex string. To solve, you decompress it (like unzipping). The message pops out. It's not really encryption — just a wrapper that requires you to know how to decompress data.
Why this really exists: Compression is how your computer stores photos (JPEG), music (MP3), and videos (H.264) in a fraction of their original size. websites serve compressed HTML (gzip) to save bandwidth — your browser decompresses it automatically. ZIP files, RAR files, and 7z archives all use compression algorithms. The zlib library used here is the same one that powers PNG images and SSH connections.
▸ Concrete Example
The compressed data in hex:
Step 1: Convert hex to bytes
Step 2: Decompress with zlib
Step 3: Decode as UTF-8 text
→ "HELLO WORLD"
data = bytes.fromhex(hex_string)
plain = zlib.decompress(data).decode('utf-8')
print(plain) # "HELLO WORLD"
▸ Decompression (Step by Step)
1. The puzzle gives you a hex string
2. Convert hex to raw bytes
3. Decompress using zlib (Python's built-in) or gunzip
4. The result is a readable message
💡 If zlib.decompress fails, the data might be raw deflate (without the zlib header). Try zlib.decompress(data, -zlib.MAX_WBITS) as a fallback.
▸ Real-World Applications
- Web pages: Servers gzip-compress HTML/CSS/JS before sending to your browser
- PNG images: Every .png file uses zlib compression internally
- SSH: Secure Shell can compress traffic to speed up remote connections
- File archives: ZIP, gzip, and 7z all use variants of the same DEFLATE algorithm
- Game assets: Video games compress textures and models to save disk space and loading time