argentini.duid
1.0.1
See the version list below for details.
dotnet add package argentini.duid --version 1.0.1
NuGet\Install-Package argentini.duid -Version 1.0.1
<PackageReference Include="argentini.duid" Version="1.0.1" />
<PackageVersion Include="argentini.duid" Version="1.0.1" />
<PackageReference Include="argentini.duid" />
paket add argentini.duid --version 1.0.1
#r "nuget: argentini.duid, 1.0.1"
#:package argentini.duid@1.0.1
#addin nuget:?package=argentini.duid&version=1.0.1
#tool nuget:?package=argentini.duid&version=1.0.1
DUID: The high entropy, web-friendly, globally unique identifier
DUID is a replacement for GUIDs (Globally Unique Identifiers) that are more compact, URL-safe, and JavaScript entity name-safe. DUIDs are 22-character alphanumeric codes that always begin with a letter. Unlike GUID v4 there is no version code which means more entropy. They have no timestamp information, so they are not sortable (which also improves strength by eliminating predictability).
Under the hood, DUIDs are generated using the latest .NET cryptographic random number generator.
You can also find DUID on nuget.
Usage
Similar to Guid.NewGuid(), you can generate a new DUID by calling the static NewDuid method:
var duid = Duid.NewDuid();
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:
var emptyDuid = Duid.Empty; // Represents an empty DUID (all zeros); "AAAAAAAAAAAAAAAAAAAAAA"
var duid = Duid.NewDuid();
var duidString = duid.ToString();
if (Duid.TryParse("aZ3x9Kf8LmN2QvW1YbXcDe", out var duid)
{
// Successfully parsed DUID
}
if (Duid.IsValidString("aZ3x9Kf8LmN2QvW1YbXcDe"))
{
// Successfully validated
}
if (duid1 == duid2)
{
// Comparison works as expected
}
There is also a JSON converter for System.Text.Json that provides seamless serialization and deserialization of DUIDs:
var options = new JsonSerializerOptions();
options.Converters.Add(new DuidJsonConverter());
var duid = Duid.NewDuid();
var json = JsonSerializer.Serialize(duid, options);
This scratches the surface of what's available. Try using DUIDs in your project to explore all the features it provides.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.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.
Initial release