vinkla/hashids

Generated the same hash id for two different id numbers

daxsis opened this issue · 2 comments

I use the latest hashids with Laravel 7 on PHP 7.4.3

Each model class has a different connection with custom salt is 40 chars long( tried 100), the length is 8 and even if I increase to 10, somehow I get 89 and 101 integer numbers the same hash.
I'm afraid that creating longer hashes won't solve the problem in the long run. Is there any way to test why it is happening? Or to make sure that I get only unique hashes?

Thank you.

Thanks for reaching out. Please add a test case to the HashidsTest class with your failing results by opening a pull request. Then we'll take it from there.

Just in case anyone will look into this issue. The actual problem was that I wanted to store hashes into db to avoid regenerating them on the fly, however these hashes are CASE SENSITIVE and if your database is case insensitive then you will have a non-unique collision.

LMQvreQ8 is 128 in my case and LMQvReQ8 is 172 :D

The solution is to generate them on the fly. I hope that the length of 8 will be enough though.