hashids.net icon indicating copy to clipboard operation
hashids.net copied to clipboard

Same hash different integers

Open johnseabi opened this issue 1 year ago • 3 comments

Hi guys

I am using this package and I really love it. However, I have run into a duplicate issue where these two Ids are hashed to the same 17 charecter string: 518441536 520571136

the resulting hash : gOnbdg2ENEBPRP5mY that is of coursing using the same Salt.

I see there was the same issue opened last year Nov and the person said they were mistaken but I am pretty sure there is an issue here.

I am actively using this package and just last week i started seeing this problem.

@ullmark is this something that is being worked on to find the root cause?

johnseabi avatar Apr 08 '24 08:04 johnseabi

@johnseabi Hi, in general there is very little being worked on with this library since the original algoritm author decided that everything should be re-done. 😏

Maybe you could create a PR with a test failing with your scenario including the has you used?

ullmark avatar Apr 08 '24 12:04 ullmark

Thanks.

Do you know do you know if there is a way for me to check the hashspace of the algorithm? I am using this in a production enviroment and I found a way around the above issue, only that dependends on me having an idea about the hashspace of the algorithm

johnseabi avatar Apr 09 '24 08:04 johnseabi

Not entirely sure what you mean here... I initially ported the much of the code from the ruby version of the library (since the author is an acquaintance of mine). Since then we've made a lot of changes ofc.

The algoritm itself comes from the javascript library and the original author @4kimov. If you do end up creating a test proving this issue and/or fixing it, you are welcome to supply a PR!

Without that test, it's going to be hard to find the issue you're having. You could also try to change to https://sqids.org/dotnet but I do believe that hashes will be different so you'd need to to a migration.

ullmark avatar Apr 25 '24 08:04 ullmark