sisong/HDiffPatch logo

sisong/HDiffPatch

Free

a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch.

FreeFree tier
Type
Open Source
Company
sisong

About sisong/HDiffPatch

HDiffPatch is a C/C++ library and command-line tool for creating and applying binary diffs and patches between files or entire directories. It is cross-platform, runs fast, produces small deltas, and handles large files while limiting memory usage. The tool defines its own patch format but is also compatible with bsdiff4 and open-vcdiff (VCDIFF RFC 3284) formats. It includes specialized modules: HPatchLite for embedded systems (MCU, NB-IoT) with ultra-low RAM (1KB) support and inplace-patching; ApkDiffPatch for smaller Android APK patches (requires re-signing); sfpatcher for app-store-friendly APK patching; and hsynz for sync scenarios similar to zsync but faster with zstd compression. HDiffPatch treats files as byte streams and does not preserve file metadata like timestamps or permissions.

Key Features

Diff and patch binary files or entire directories
Cross-platform support (Windows, Linux, macOS, Android)
Creates small delta/differential files
Handles large files with limited memory requirements
Compatible with bsdiff4 and open-vcdiff (VCDIFF RFC 3284) patch formats
HPatchLite for embedded systems (MCU, NB-IoT) with tinyuz decompressor, runs on 1KB RAM devices
Inplace-patch support for storage-constrained devices
ApkDiffPatch for smaller Android APK deltas (requires re-signing)
sfpatcher for Android app store APK patching without re-signing
hsynz sync tool (like zsync) with zstd compression for faster sync

Pros & Cons

Pros
  • Open source and free to use
  • Cross-platform (Windows, Linux, macOS, Android)
  • Fast diff and patch operations
  • Generates very small delta files
  • Low memory usage, suitable for large files and constrained devices
  • Compatible with other popular patch formats (bsdiff, VCDIFF)
  • Includes specialized tools for Android and embedded systems
  • Supports both file-level and directory-level patching
Cons
  • Does not preserve file metadata (permissions, timestamps, symlinks, etc.)
  • ApkDiffPatch requires re-signing APKs, limiting use in app stores
  • No built-in text-aware diffing (pure binary approach)
  • Documentation is primarily the README on GitHub, may lack extensive examples
  • Learning curve for integrating the library into existing projects

Best For

Over-the-air (OTA) updates on embedded systems and IoT devicesAndroid APK incremental updates (app store or direct)Binary file patching for software distributionDirectory synchronization and differential backupSync scenarios where only new file version is available (using hash certificates)Patching large files (e.g., firmware, game assets) with low memory footprint

FAQ

What is HDiffPatch?
HDiffPatch is a C/C++ library and command-line tool for creating and applying binary diffs and patches between files or directories. It is designed to be cross-platform, fast, produce small deltas, and support large files with limited memory.
Does HDiffPatch support directory patching?
Yes, HDiffPatch provides command-line tools and APIs for diffing and patching entire directories (folders).
Is HDiffPatch compatible with other patch formats?
Yes, HDiffPatch defines its own patch format but is also compatible with bsdiff4 and open-vcdiff (VCDIFF RFC 3284) formats.
Can HDiffPatch be used on embedded devices with very little RAM?
Yes, HPatchLite is a demo that uses the tinyuz decompressor and can run on devices with only 1KB of RAM. It also supports inplace-patching for storage-constrained devices.
How does HDiffPatch handle Android APK updates?
HDiffPatch offers ApkDiffPatch for creating smaller APK deltas (requires re-signing) and sfpatcher for app store use that does not require re-signing, and runs faster with O(1) memory.