Skip to content
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

Closed
bcollierjones opened this issue Feb 18, 2019 · 5 comments
Closed

Comments

@bcollierjones
Copy link

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.

@andreystepanov
Copy link
Owner

Thanks for your finding.
I will try to check this bug out!

And you can make a PR, for example :)

@gasi
Copy link

gasi commented Apr 6, 2019

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 😄

@rutchkiwi
Copy link

@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.

@braco
Copy link

braco commented May 31, 2020

Seems like this PR might fix? #4

@dguo
Copy link

dguo commented Jun 25, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants