initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
namespace Indotalent.Shared.Utils;
|
||||
|
||||
public static class SequentialGuidGenerator
|
||||
{
|
||||
public static string NewSequentialId()
|
||||
{
|
||||
byte[] guidBytes = Guid.NewGuid().ToByteArray();
|
||||
|
||||
byte[] timestampBytes = BitConverter.GetBytes(DateTime.UtcNow.Ticks);
|
||||
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(timestampBytes);
|
||||
}
|
||||
|
||||
guidBytes[10] = timestampBytes[2];
|
||||
guidBytes[11] = timestampBytes[3];
|
||||
guidBytes[12] = timestampBytes[4];
|
||||
guidBytes[13] = timestampBytes[5];
|
||||
guidBytes[14] = timestampBytes[6];
|
||||
guidBytes[15] = timestampBytes[7];
|
||||
|
||||
return new Guid(guidBytes).ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user