Custom alphabet produces different results than other libraries
bcollierjones opened this issue · 5 comments
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.
Thanks for your finding.
I will try to check this bug out!
And you can make a PR, for example :)
First of all, thanks for writing this library. I spent quite some time integrating the plv8
version until I had a hard time getting it running in CI and then learning that AWS RDS doesn’t like either 😉
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.