Skip to content

handicraftsman/UUIDj47

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UUIDj47

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.

Installation

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.

Usage

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
    }
}

Benchmarks

# 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/op

So currently the original C library is around four times faster.

I am working on improving the performance.

About

A library for UUID v7 <-> v4 conversion using SipHash masking.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages