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.
- 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.
sudo apt update
sudo apt install -y build-essential    # only if g++ is missing
g++ -std=c++17 -O2 -Wall -o compressor compressor.cpp./compressor -c input.file output.huf
# example
./compressor -c mybook.pdf mybook.huf./compressor -d output.huf restored.file
# example
./compressor -d mybook.huf mybook_restored.pdfAfter 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"This project is licensed under the MIT License.

