You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KSUID is for K-Sortable Unique IDentifier. It's a way to generate globally unique IDs similar to RFC 4122 UUIDs, but contain a time component so they can be "roughly" sorted by time of creation. The remainder of the KSUID is randomly generated bytes.
Installation
To install Ksuid, run the following command in the Package Manager Console
PM>Install-Package Ksuid
Usage
usingKSUID;varksuid1=Ksuid.Generate();// same as new Ksuid()Console.WriteLine(ksuid1);Console.WriteLine(ksuid1.GetTimestamp());Console.WriteLine(ksuid1.GetUnixTimestamp());varksuid2=Ksuid.FromString("0o5Fs0EELR0fUjHjbCnEtdUwQe3");Console.WriteLine(ksuid2);Console.WriteLine(ksuid2.GetTimestamp());Console.WriteLine(ksuid2.GetUnixTimestamp());varksuid3=newKsuid(ksuid2.GetPayload());Console.WriteLine(ksuid3);Console.WriteLine(ksuid3.GetTimestamp());Console.WriteLine(ksuid3.GetUnixTimestamp());varksuid4=newKsuid(ksuid2.GetPayload(),ksuid1.GetTimestamp());Console.WriteLine(ksuid4);Console.WriteLine(ksuid4.GetTimestamp());Console.WriteLine(ksuid4.GetUnixTimestamp());varksuid4=Ksuid.FromByteArray(ksuid2.ToByteArray());Console.WriteLine(ksuid4);