UUID version 5 produces incorrect results
zygisx opened this issue · 4 comments
It seems that version 5 generated UUIDs are incorrect.
I tried various other generators and they produce different result then this library. Here is link to one of them: https://www.uuidtools.com/v5
Data i tried:
Namespace: a4405a8d-8bb2-467a-bbc3-961ab93bb538
Name: 9912310000
Expected: a045c4bc-d81c-5fc4-88bd-313db5b2d1fc
Unit test
[Fact]
public void GeneratesCorrectV5UUID()
{
var uuidNamespace = Guid.Parse("a4405a8d-8bb2-467a-bbc3-961ab93bb538");
var name = "9912310000";
var generator = new NameBasedGenerator(HashType.SHA1);
var uuidV5 = generator.GenerateGuid(uuidNamespace, name);
Assert.Equal("a045c4bc-d81c-5fc4-88bd-313db5b2d1fc", uuidV5.ToString());
}
I'm using .net core v3.1
It appears to me that in your implementation, you missed the errata for rfc4122, which is making (at minimum, I haven't checked the other types) all of your name-based guids incorrect.
/cc @zpbappi
Thank you @zygisx for such a detailed report. It appears we have missed how array of bytes are treated by .NET Guid
when converting between byte[]
and Guid
. This should be fixed with the PR #8
@BMurri I am not entirely sure which part you are referring to. Can you please give an example? Possibly, something like- "I want this which is not happening or not present".