Skip to content

A fast and simple Huffman-based compression tool written in C++ for compressing and decompressing large files.

License

Notifications You must be signed in to change notification settings

dunstanad/Compression-Tool

Repository files navigation

Compression Tool

Lightweight Huffman file compressor in C++. Single-source implementation (compressor.cpp) with support for compressing and restoring any type of file, including edge cases like empty or uniform data.


🔧 Features

  • Implements lossless Huffman coding for any binary file (text, PDFs, images, executables).
  • Entire logic in a single C++ file for clarity and quick modification.
  • Correctly processes special cases such as empty inputs or files with only one symbol.
  • Self-contained format: stores symbol frequencies in the header so files can be decompressed without external metadata.

🛠️ Usage

Build (WSL / Linux / macOS)

sudo apt update
sudo apt install -y build-essential    # only if g++ is missing
g++ -std=c++17 -O2 -Wall -o compressor compressor.cpp

Compress

./compressor -c input.file output.huf
# example
./compressor -c mybook.pdf mybook.huf

Decompress

./compressor -d output.huf restored.file
# example
./compressor -d mybook.huf mybook_restored.pdf

🛡️ Verify (integrity)

After decompression, verify the original and restored files are identical:

# compare checksums
sha256sum mybook.pdf mybook_restored.pdf

# or direct binary compare
cmp --silent mybook.pdf mybook_restored.pdf && echo "OK: identical"

💻 Screenshots

Compress and Decompress Files

Compress & Decompress file

Verify Decompressed & Original Files

Hex Dump Output


📄 License

This project is licensed under the MIT License.

About

A fast and simple Huffman-based compression tool written in C++ for compressing and decompressing large files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages