A library for UUID v7 <-> v4 conversion using SipHash masking.
This is a direct port of the uuidv47 C library, except for the Postgres extension.
Currently, the only way to use this library is to build it from source.
Will publish it to Maven Central once I feel it's ready to use.
package com.example;
import io.github.handicraftsman.uuidj47.UUIDj47;
import java.util.UUID;
public class Demo {
public static void main(String[] args) {
UUIDj47 tool = UUIDj47.withRandomKey(); // or `new UUIDj47(sipK0, sipK1)`
UUID v7 = /* some uuid */;
UUID v4 = tool.encrypt(v7);
UUID restoredV7 = tool.decrypt(v4);
// v7 == restoredV7
// v7 != v4
}
}# C library benchmark on a Mac Mini m4:
encode+decode : 21.00 ns/op (47.6 Mops/s)
# UUIDj47 benchmark on the same Mac Mini m4:
Benchmark Mode Cnt Score Error Units
UUIDj47Benchmark.benchmarkEncryptDecrypt avgt 5 84.107 ± 8.347 ns/opSo currently the original C library is around four times faster.
I am working on improving the performance.