unique 0.0.1
dotnet add package unique --version 0.0.1
NuGet\Install-Package unique -Version 0.0.1
<PackageReference Include="unique" Version="0.0.1" />
paket add unique --version 0.0.1
#r "nuget: unique, 0.0.1"
// Install unique as a Cake Addin #addin nuget:?package=unique&version=0.0.1 // Install unique as a Cake Tool #tool nuget:?package=unique&version=0.0.1
unique
Unique allows for the creation of a "Deterministic Guid" which will be unique in a SpaceId over time with a high probability. The same Guid
will be generated for a given Namespace ID and name.
Usage
In C# using Unique.CSharp
you can use NamedGuid.NewGuid
to generate a new Guid. You can check the version of the generated Guid
by passing a Guid
to Version
.
// C# example
using Unique.CSharp;
//...
// Use the pre-defined DNS namespace
Guid uniqueIdForDns = NamedGuid.NewGuid(SpaceId.DNS, "example.com");
Console.WriteLine($"DNS example.com ID is {uniqueIdForDns}");
// OUTPUT: DNS example.com ID is cfbff0d1-9375-5685-968c-48ce8b15ae17
// Use a custom namespace Guid
Guid customGuid = Guid.Parse("AA0F4712-691F-4C72-B5EC-19730324EAFD");
Guid uniqueIdForCustomSpace = NamedGuid.NewGuid(customGuid, "bob@builder.com");
Console.WriteLine($"Custom bob@builder.com ID is {uniqueIdForCustomSpace}");
// OUTPUT: Custom bob@builder.com ID is dbead1ff-3f86-5d73-b577-cb00ee3fccaf
// Get the version of any Guid
int version = NamedGuid.Version(uniqueIdForCustomSpace);
Console.WriteLine($"Version is {version}");
// OUTPUT: Version is 5
// Since the default hash algorithm is SHA-1 the version is always 5
// Use Unique.NamedGuid.newGuid to define the hash algorithm.
version = NamedGuid.Version(Guid.NewGuid());
Console.WriteLine($"Version is {version}");
// OUTPUT: Version is 4
If you need to generate using a byte[]
or change the algorithm, use the functions found on Unique.NamedGuid
, Unique.NS
and Unigue.Algorithm
.
// F# example
let guid = NamedGuid.newGuid Algorithm.MD5 NS.DNS "www.example.com"
// val: 5df41881-3aed-3515-88a7-2f4a814cf09e
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.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 was computed. |
.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
- FSharp.Core (>= 6.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 2,915 | 4/21/2023 |