-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom alphabet produces different results than other libraries #2
Comments
Thanks for your finding. And you can make a PR, for example :) |
First of all, thanks for writing this library. I spent quite some time integrating the I noticed the same after setting up a randomized test comparing the JavaScript against this PL/pgSQL implementation: https://github.com/zoomhub/hashids-test/tree/35b61782d13fe5e896f32022ef445b34c764738b#quickstart The good news: The implementation with default alphabet seems to match 😄 |
@andreystepanov did you ever make any headway on this? I would love to use this and was trying to figure out a bugfix but the combination of not being good at plpgsql and not understanding the hashid algorithm makes it very hard.. I don't know what it could be considering that when you pass in the default alphabet explicitly it still returns the same result as the clojure and python implementations. |
Seems like this PR might fix? #4 |
For what it's worth, I tested #4 against a significant amount of production data (using a custom alphabet) and compared it to the results from the JavaScript implementation of Hashids. They matched in all cases! |
Thank you for getting this off the ground! In doing some playing around I noticed that I got different results when I used a custom alphabet using your library than through the Javascript or Ruby versions.
I used this codepen from Ivan Akimov to test the JS version:
https://codepen.io/ivanakimov/pen/bNmExm
ID: 1 / salt: 'salt' / no custom alphabet - OK
Javascript: XG
Ruby: XG
PL/SQL: XG
ID: 1 / min_length: 6 / salt: 'salt' / no custom alphabet - OK
Javascript: xkXG8Z
Ruby: xkXG8Z
PL/SQL: xkXG8Z
ID: 1 / min_length: 6 / salt: 'salt' / alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - ERROR
Javascript: MEPWMP
Ruby: MEPWMP
PL/SQL: JPRAPM
I wish I could offer more assistance.
The text was updated successfully, but these errors were encountered: