array-analytics / plpg_hashids

Short unique id generator for PostgreSQL in plpgsql, using hashids.org
MIT License
36 stars 8 forks source link

Result differs from javascript implementation #13

Closed ChickenProp closed 2 years ago

ChickenProp commented 3 years ago

Two inconsistencies:

# select hashids.encode_list('{1,1}'::int[], '', 0, '12356789abcdefgh'), 
         hashids.encode_list('{1,1}'::int[], '', 0, '123456789:;<=>?@ABCD');
NOTICE:  {1,1}[1]: 1 for 2
NOTICE:  {1,1}[2]: 1 for 2
NOTICE:  {1,1}[1]: 1 for 2
NOTICE:  {1,1}[2]: 1 for 2
 encode_list | encode_list 
-------------+-------------
 6316        | :<2=
(1 row)

But according to the javascript implementation at https://codepen.io/glenndevenish/pen/EwYjbJ, these should be 63f6 and :<1= respectively. The haskell implementation at https://github.com/laserpants/hashids-haskell gives the same results as the javascript one.

rhux commented 2 years ago

Thank you for finding this. I believe it is now fixed with this commit: https://github.com/array-analytics/plpg_hashids/commit/c17d5a8b4562e3ef261ba546a18eac3eafb88830