DUID is a fully-featured replacement for GUIDs (Globally Unique Identifiers). They are more compact, web-friendly, and provide more entropy than GUIDs. We created this UUID type as a replacement for GUIDs in our projects, improving on several GUID shortcomings.
We pronounce it doo-id, but it can also be pronounced like dude, which is by design :)
You can use DUIDs as IDs for user accounts and database records, in JWTs, as unique code entity (e.g. variable) names, and more. They're an ideal replacement for GUIDs that need to be used in web scenarios.
Uses the latest .NET cryptographic random number generator
More entropy than GUID v4 (128 bits vs 122 bits)
No embedded timestamp (reduces predictability and improves strength)
Self-contained; does not use any packages
High performance, with minimal allocations
16 bytes in size; 22 characters as a string
Always starts with a letter (can be used as-is for programming language variable names)
URL-safe
Can be validated, parsed, and compared
Can be created from and converted to byte arrays
UTF-8 encoding support
JSON serialization support
TypeConverter support
Debug support (displays as string in the debugger)
Yes, you can also find DUID on nuget. Look for the package named fynydd.duid.
Similar to Guid.NewGuid(), you can generate a new DUID by calling the static NewDuid() method:
This will produce a new DUID, for example: aZ3x9Kf8LmN2QvW1YbXcDe. There are a ton of overloads and extension methods for converting, validating, parsing, and comparing DUIDs.
Here are some examples:
There is also a JSON converter for System.Text.Json that provides seamless serialization and deserialization of DUIDs:
There's usually more to the story so if you have questions or comments about this post let us know!
Do you need a new software development partner for an upcoming project? We would love to work with you! From websites and mobile apps to cloud services and custom software, we can help!