DeterministicGuids 1.0.3
See the version list below for details.
dotnet add package DeterministicGuids --version 1.0.3
NuGet\Install-Package DeterministicGuids -Version 1.0.3
<PackageReference Include="DeterministicGuids" Version="1.0.3" />
<PackageVersion Include="DeterministicGuids" Version="1.0.3" />
<PackageReference Include="DeterministicGuids" />
paket add DeterministicGuids --version 1.0.3
#r "nuget: DeterministicGuids, 1.0.3"
#:package DeterministicGuids@1.0.3
#addin nuget:?package=DeterministicGuids&version=1.0.3
#tool nuget:?package=DeterministicGuids&version=1.0.3
DeterministicGuids
A small, allocation-conscious, thread-safe .NET utility for generating name-based deterministic UUIDs (a.k.a. GUIDs) using RFC 4122 version 3 (MD5) and version 5 (SHA-1).
You give it:
- a namespace GUID (for a logical domain like "Orders", "Users", "Events")
- a name (string within that namespace)
- and (optionally) the UUID version (3 or 5).
If you don't specify it, it defaults to version 5 (SHA-1).
It will always return the same GUID for the same (namespace, name, version) triplet.
This is useful for:
- Stable IDs across services or deployments
- Idempotent commands / events
- Importing external data but keeping predictable identifiers
- Deriving IDs from business keys without storing a lookup table
Features
✅ Deterministic
Same(namespace, name, version)→ same output every time.✅ Standards-based
Implements RFC 4122 §4.3 for UUIDv3 (MD5-based) and UUIDv5 (SHA-1-based).✅ Thread-safe
No shared mutable state, no static caches, no locks. You can call it from many threads at once.✅ Optimized memory profile
- Uses
Span<byte>andstackallocfor fixed-size work. - Uses
ArrayPool<byte>for variable-length buffers (the UTF-8 input string), instead of allocating on every call. - Uses incremental hashing on modern runtimes, so we never build a giant
namespace+nameconcatenated array.
- Uses
✅ Zero runtime GUID parsing for known namespaces
Namespaces are defined using the numericGuidconstructor, notGuid.Parse(...), so there is no string parsing cost at first use.✅ Multi-targeted
netstandard2.0netstandard2.1net8.0(and above)
On newer targets we take advantage of newer BCL APIs to reduce allocations to near zero.
Quick Start
using DeterministicGuids;
// Choose a namespace (either one of the built-ins or your own Guid)
var ns = DeterministicGuid.Namespaces.Events;
// Define the stable name/key within that namespace
var key = "order:12345";
// Generate a deterministic GUID.
// This uses version 5 (SHA-1) by default.
Guid idV5 = DeterministicGuid.Create(ns, key);
Console.WriteLine(idV5);
// Same ns + key + version (5) will always produce the same Guid
Benchmarks
DeterministicGuids stacks very well against other libraries in terms of speed and memory usage. Here are some benchmarks with values taken directly from a run in GitHub Actions.
| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|
| DeterministicGuids | 1.021 us | 0.0012 us | 0.0009 us | 1.00 | - | - | NA |
| Be.Vlaanderen.Basisregisters.Generators.Guid.Deterministic | 1.494 us | 0.0061 us | 0.0054 us | 1.46 | 0.0744 | 1264 B | NA |
| UUIDNext | 1.085 us | 0.0026 us | 0.0022 us | 1.06 | 0.0572 | 960 B | NA |
| NGuid | 1.153 us | 0.0016 us | 0.0015 us | 1.13 | - | - | NA |
Credits
Check out our list of contributors!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory (>= 4.6.3)
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Small optimization.