csharpvitamins / CSharpVitamins.ShortGuid

A convenience wrapper for dealing with base64 encoded Guids
MIT License
103 stars 20 forks source link

Different ShortGuids result in same Guid #7

Closed amcorch closed 3 years ago

amcorch commented 3 years ago

Is the intent that a ShortGuid and Guid will map one-to-one? I have the following scenario where two different ShortGuids map to the same Guid.

var sourceGuid = Guid.Parse("a021b760-f451-495a-8fc0-c9b30c489300");

var guid1 = ShortGuid.Decode("YLchoFH0WkmPwMmzDEiTAA");
var guid2 = ShortGuid.Decode("YLchoFH0WkmPwMmzDEiTAB");

var equal = guid1 == guid2;
var equal2 = guid1 == sourceGuid;
var equal3 = sourceGuid == guid2;

Console.WriteLine(equal);
Console.WriteLine(equal2);
Console.WriteLine(equal3);
davetransom commented 3 years ago

Basically, yes it should.

I think you're running into a similar thing explained here => https://github.com/csharpvitamins/CSharpVitamins.ShortGuid/pull/4#issuecomment-688527901

There are plans to fix this so it behaves in a stricter fashion. I've just forgotten about merging the PR and finishing the implementation (a breaking change).

davetransom commented 3 years ago

An update is available that ensures this no longer happens.