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.

GitHub: Avalanche-io/libc4

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:

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.