UuidToolkit
September 1, 2025 · View on GitHub
Namespace: UUIDNext.Tools
Provite a set of static methods for generating custom UUIDs
public static class UuidToolkit
Inheritance Object → UuidToolkit
Methods
CreateUuidV7FromSpecificDate(DateTimeOffset)
Create a new UUID version 7 with the given date as timestamp
public static Guid CreateUuidV7FromSpecificDate(DateTimeOffset date)
Parameters
date DateTimeOffset
Returns
CreateUuidV7(Int64, Span<Byte>)
Create a new UUID version 7 with the given timestamp and bytes of otherBytes, filling the rest with random data
public static Guid CreateUuidV7(long timestamp, Span<byte> followingBytes)
Parameters
timestamp Int64
A unix epoch timestamp in ms
followingBytes Span<Byte>
A series of 0 to 10 bytes used to fill the rest of the UUID.
Be careful: some bits will be overxritten by the version and variant of the UUID (see remarks)
Returns
Guid
A UUID Version 7
Exceptions
Remarks:
Here is the bit layout of the UUID Version 7 created
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp | ver | otherBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var| otherBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| otherBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
CreateSequentialUuidForSqlServerFromSpecificDate(DateTimeOffset)
Create a new sequential UUID Optimised for SQL Server with the given date as timestamp
public static Guid CreateSequentialUuidForSqlServerFromSpecificDate(DateTimeOffset date)
Parameters
date DateTimeOffset
Returns
CreateGuidFromBigEndianBytes(Span<Byte>)
Create new UUID version 8 with the provided bytes with the variant and version bits set
public static Guid CreateGuidFromBigEndianBytes(Span<byte> bigEndianBytes)
Parameters
bigEndianBytes Span<Byte>
the bytes that will populate the UUID in big endian order
Returns
Guid
a UUID version 8
Remarks:
Here is the bit layout of the UUID Version 8 created :
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| bigEndianBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| bigEndianBytes | ver | bigEndianBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var| bigEndianBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| bigEndianBytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
CreateUuidFromName(Guid, String, HashAlgorithm)
Create a new name based UUID version 8 according to section 6.5 of the RFC
public static Guid CreateUuidFromName(Guid namespaceId, string name, HashAlgorithm hashAlgorithm)
Parameters
namespaceId Guid
the namespace where the name belongs
name String
the name to be hashed
hashAlgorithm HashAlgorithm
the hash algorithm used to compute the UUID (MD5, SHA-256, etc.)
Returns
Guid
A UUID version 8