stateless-me/uuidv47
Free⚡ UUIDv47 = v4 privacy + v7 performance
About stateless-me/uuidv47
UUIDv47 is a header-only C library (C89) that provides a deterministic, invertible mapping between UUIDv7 (time-ordered) and UUIDv4-looking façades. It XOR-masks only the timestamp field of a UUIDv7 with a keyed SipHash‑2‑4 stream derived from the UUID's own random bits, preserving the random bits unchanged. This allows storing sortable UUIDv7 in databases for better index locality and pagination while emitting a UUIDv4-compliant façade at the API boundary to avoid revealing internal timing patterns. The library is RFC-compatible (version/variant bits), includes a full test suite, and offers an optional PostgreSQL extension with custom UUID type, operators, and opclasses. It is designed for key-recovery resistance via SipHash‑2‑4 with a 128-bit key.
Key Features
Pros & Cons
- Improves database indexing and pagination due to UUIDv7 time-ordering
- Maintains UUIDv4 look externally to avoid revealing internal timing
- Deterministic and reversible transformation
- Strong security with SipHash‑2‑4 keyed hashing
- Lightweight header-only C library with no dependencies
- Includes comprehensive tests and optional PostgreSQL extension
- Only works with UUIDv7 as input; requires existing v7 UUIDs
- Requires secret key management for the SipHash key
- Additional computational overhead for masking/unmasking
- Relies on SipHash, which is a PRF and not suitable for cryptographic-grade security if slower hashes are needed
- Limited to C/C++ projects unless ports are used