Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

jspatel/tuid-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TUID Processor

What is this?

It is an extension for the Chrome browser to dissect and generate TUID. You can install it from Chrome Store.

What is TUID?

TUID stands for Time based unique identifier. TUID is a 64 bit long unsigned integer value.

How can I generate one?

It is generated using epoch, and some random value. It is constructed using three segments; epoch, serverid, and a counter value. You can add or remove different bit segments.

Following is the sample code (untested) to generate TUID in Java.

//You can change the distribution of number of bits between segaments
static short counter = 1;
static byte serverid = 50;
public long generateTuid(){
    long epoch =  System.currentTimeMillis();
    //Increament counter between tuid generation call to avoid duplicates
    counter++;
    if(counter >= 1022){
        counter = 1;
    }
    long tuid = ( epoch << 18) + (counter << 10) + sreverid;
    return tuid;
}

Based on the above example, the bit segments distribution looks like following.

Epoch Counter Server id
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00 00 0000 0000 0000 0000
  • Max Epoch 2^46 = 70,368,744,177,664 = GMT: Sun, 24 Nov 4199 01:22:57.664
  • Max Counter 2^10 = 1,024
  • Max Server id 2^8 = 256

Note

This extension only works with specific bit segments.

Epoch (46 bits) + Counter (10 bits) + Server id (8 bits) == Tuid (64 bites)

Credits

This project uses

About

Chrome extension to dissect and generate TUID

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages