Skip to content

Commit

Permalink
Update URLs to rfc-editor.org.
Browse files Browse the repository at this point in the history
This has a better display of the RFCs.
  • Loading branch information
bgrainger committed Oct 5, 2024
1 parent 9120efe commit 7372ffd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
## About

NGuid provides efficient creation of name-based, time-based, and random GUIDs according to
[RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
and [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562):
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122)
and [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562):

* Version 3 ‒ created from an MD5 hash of a name
* Version 5 ‒ created from a SHA1 hash of a name
Expand Down
10 changes: 5 additions & 5 deletions src/NGuid/GuidHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace NGuid;
public static class GuidHelpers
{
/// <summary>
/// Creates a name-based UUID using the algorithm from <a href="https://datatracker.ietf.org/doc/html/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// Creates a name-based UUID using the algorithm from <a href="https://www.rfc-editor.org/rfc/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// </summary>
/// <param name="namespaceId">The ID of the namespace.</param>
/// <param name="name">The name (within that namespace). This string will be converted to UTF-8
Expand Down Expand Up @@ -43,7 +43,7 @@ public static Guid CreateFromName(Guid namespaceId, string name, int version = 5
}

/// <summary>
/// Creates a name-based UUID using the algorithm from <a href="https://datatracker.ietf.org/doc/html/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// Creates a name-based UUID using the algorithm from <a href="https://www.rfc-editor.org/rfc/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// </summary>
/// <param name="namespaceId">The ID of the namespace.</param>
/// <param name="name">The name (within that namespace).</param>
Expand Down Expand Up @@ -90,7 +90,7 @@ public static Guid CreateFromName(Guid namespaceId, byte[] name, int version = 5

#if NET6_0_OR_GREATER
/// <summary>
/// Creates a name-based UUID using the algorithm from <a href="https://datatracker.ietf.org/doc/html/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// Creates a name-based UUID using the algorithm from <a href="https://www.rfc-editor.org/rfc/rfc4122#section-4.3">RFC 4122 §4.3</a>.
/// </summary>
/// <param name="namespaceId">The ID of the namespace.</param>
/// <param name="name">The name (within that namespace).</param>
Expand Down Expand Up @@ -379,7 +379,7 @@ public static Guid CreateVersion8(ReadOnlySpan<byte> bytes)

/// <summary>
/// Creates a Version 8 UUID from a name in the specified namespace using the specified hash algorithm, according to the algorithm
/// in <a href="https://datatracker.ietf.org/doc/html/rfc9562#name-name-based-uuid-generation">RFC 9562, section 6.5</a>.
/// in <a href="https://www.rfc-editor.org/rfc/rfc9562#name-name-based-uuid-generation">RFC 9562, section 6.5</a>.
/// </summary>
/// <param name="hashAlgorithmName">The name of the hash algorithm to use. Supported values are <c>SHA256</c>, <c>SHA384</c>, and <c>SHA512</c>.</param>
/// <param name="namespaceId">The namespace ID.</param>
Expand Down Expand Up @@ -417,7 +417,7 @@ public static Guid CreateVersion8FromName(HashAlgorithmName hashAlgorithmName, G
#if NET6_0_OR_GREATER
/// <summary>
/// Creates a Version 8 UUID from a name in the specified namespace using the specified hash algorithm, according to the algorithm
/// in <a href="https://datatracker.ietf.org/doc/html/rfc9562#name-name-based-uuid-generation">RFC 9562, section 6.5</a>.
/// in <a href="https://www.rfc-editor.org/rfc/rfc9562#name-name-based-uuid-generation">RFC 9562, section 6.5</a>.
/// </summary>
/// <param name="hashAlgorithmName">The name of the hash algorithm to use. Supported values are <c>SHA256</c>, <c>SHA384</c>, and <c>SHA512</c>.</param>
/// <param name="namespaceId">The namespace ID.</param>
Expand Down
4 changes: 2 additions & 2 deletions src/NGuid/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## NGuid

NGuid provides efficient creation of name-based, time-based, and random GUIDs according to
[RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
and [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562):
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122)
and [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562):

* Version 3 ‒ created from an MD5 hash of a name
* Version 5 ‒ created from a SHA1 hash of a name
Expand Down
12 changes: 6 additions & 6 deletions tests/NGuid.Tests/GuidHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void CreateGuidFromDnsName(string name, int version, string expected) =>
[Theory]
[InlineData("www.terraform.io", 5, "a5008fae-b28c-5ba5-96cd-82b4c53552d6")] // https://developer.hashicorp.com/terraform/language/functions/uuidv5
[InlineData("www.example.org", 5, "74738ff5-5367-5958-9aee-98fffdcd1876")] // https://stackoverflow.com/a/5541986/23633
[InlineData("www.example.com", 3, "5df41881-3aed-3515-88a7-2f4a814cf09e")] // https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#name-example-of-a-uuidv3-value
[InlineData("www.example.com", 5, "2ed6657d-e927-568b-95e1-2665a8aea6a2")] // https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#name-example-of-a-uuidv5-value
[InlineData("www.example.com", 3, "5df41881-3aed-3515-88a7-2f4a814cf09e")] // https://www.rfc-editor.org/rfc/rfc9562#name-example-of-a-uuidv3-value
[InlineData("www.example.com", 5, "2ed6657d-e927-568b-95e1-2665a8aea6a2")] // https://www.rfc-editor.org/rfc/rfc9562#name-example-of-a-uuidv5-value
public void CreateGuidFromAsciiDnsName(string name, int version, string expected) =>
Assert.Equal(new Guid(expected), GuidHelpers.CreateFromName(GuidHelpers.DnsNamespace, Encoding.ASCII.GetBytes(name), version));

Expand Down Expand Up @@ -68,7 +68,7 @@ public void CreateV6()
var timeLow = BinaryPrimitives.ReadUInt16LittleEndian(bytes.AsSpan(6)) & 0xFFFu;
var timestamp = (long) ((((ulong) timeHigh) << 28) | ((ulong) timeMid << 12) | timeLow);

// adjust epoch to Windows NT FILETIME (from get_system_time in https://datatracker.ietf.org/doc/html/rfc4122)
// adjust epoch to Windows NT FILETIME (from get_system_time in https://www.rfc-editor.org/rfc/rfc4122)
timestamp -=
(1000 * 1000 * 10L) // seconds
* (60 * 60 * 24L) // days
Expand All @@ -81,7 +81,7 @@ public void CreateV6()
#if NET8_0_OR_GREATER
[Theory]
[InlineData("1998-02-04T22:13:53.151183Z", "1d19dad6-ba7b-6816")] // timestamp from the RFC 4122 example; see the date on this draft: https://datatracker.ietf.org/doc/html/draft-leach-uuids-guids-01
[InlineData("2022-02-22T14:22:22-05:00", "1ec9414c-232a-6b00")] // https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#name-example-of-a-uuidv6-value
[InlineData("2022-02-22T14:22:22-05:00", "1ec9414c-232a-6b00")] // https://www.rfc-editor.org/rfc/rfc9562#name-example-of-a-uuidv6-value
public void CreateV6FromTimeProvider(string timestamp, string expectedPrefix)
{
var timeProvider = new FixedTimeProvider(DateTimeOffset.Parse(timestamp, System.Globalization.CultureInfo.InvariantCulture));
Expand All @@ -106,7 +106,7 @@ public void CreateV7()

#if NET8_0_OR_GREATER
[Theory]
[InlineData("2022-02-22T14:22:22-05:00", "017f22e2-79b0-7")] // https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#name-example-of-a-uuidv7-value
[InlineData("2022-02-22T14:22:22-05:00", "017f22e2-79b0-7")] // https://www.rfc-editor.org/rfc/rfc9562#name-example-of-a-uuidv7-value
public void CreateV7FromTimeProvider(string timestamp, string expectedPrefix)
{
var timeProvider = new FixedTimeProvider(DateTimeOffset.Parse(timestamp, System.Globalization.CultureInfo.InvariantCulture));
Expand Down Expand Up @@ -176,7 +176,7 @@ public void CreateV8FromNewSpan() =>
#endif

[Theory]
[InlineData("SHA256", "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "www.example.com", "5c146b14-3c52-8afd-938a-375d0df1fbf6")] // https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#name-example-of-a-uuidv8-value-n
[InlineData("SHA256", "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "www.example.com", "5c146b14-3c52-8afd-938a-375d0df1fbf6")] // https://www.rfc-editor.org/rfc/rfc9562#name-example-of-a-uuidv8-value-n
public void CreateV8FromName(string algorithmName, string namespaceId, string name, string expected) =>
Assert.Equal(new Guid(expected), GuidHelpers.CreateVersion8FromName(new(algorithmName), new(namespaceId), Encoding.ASCII.GetBytes(name)));

Expand Down

0 comments on commit 7372ffd

Please sign in to comment.