Skip to content

Instantly share code, notes, and snippets.

View deloorc's full-sized avatar
👨‍💻
Learning new things

Cédric De Loor ☕ deloorc

👨‍💻
Learning new things
View GitHub Profile
@deloorc
deloorc / DeterministicGuid.cs
Last active January 7, 2025 15:30
A deterministic GUID generator in C# adhering to RFC 4122 specifications. This implementation supports both Version 3 (MD5) and Version 5 (SHA-1) UUIDs, using modern .NET features. Ideal for applications requiring consistent and unique identifier generation based on namespaces and names.
/// <summary>
/// Provides methods to create deterministic (name-based) GUIDs following
/// <a href="https://datatracker.ietf.org/doc/html/rfc4122">RFC 4122</a> specifications.
/// </summary>
public static class DeterministicGuid
{
private const int STACK_THRESHOLD = 1024; // 1 KB for UTF-8 bytes
private const int REQUIRED_GUID_BYTE_LENGTH = 16;
/// <summary>