libc4 — C/C++ Library
libc4 is a C implementation of C4 content identification. Embed content identity computation directly in native applications, embedded systems, or any language with a C FFI.
Build
libc4 uses CMake:
git clone https://github.com/Avalanche-io/libc4.git
cd libc4
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build
Usage
#include <c4/c4.h>
// Allocate an ID
c4_id_t *id = c4_id_new();
// Compute a C4 ID from a buffer
c4_identify(buffer, length, id);
// Print the ID
char str[C4_ID_LEN + 1];
c4_id_string(id, str, sizeof(str));
printf("C4 ID: %s\n", str);
// Clean up
c4_id_free(id);
Why C?
Not every environment runs Go or Python. libc4 provides C4 identification for:
- Embedded systems — cameras, storage controllers, hardware devices
- Performance-critical paths — when you need to hash terabytes per second
- Language bindings — any language with C FFI can use libc4 (Ruby, Rust, Swift, etc.)
- Existing C/C++ codebases — integrate content identity without rewriting
Compatibility
libc4 produces the same C4 IDs as every other tool in the ecosystem. A file identified by libc4 will have the same ID when identified by c4, c4py, or any other C4 implementation. The format is the standard — implementations just compute it.