speps/go-hashids

Javascript compatibility

olebedev opened this issue · 9 comments

Is that okey that javascript and golang implementation is not compatible?
Thanks!

Probably not, I'll investigate as soon as I can. I'll gladly accept pull requests as well if you want to have a go at fixing it yourself.

I am ready to do it. Maybe you can give me some tips about how it possible to fix it?

It's been a while since I looked at this code but the implementation is very similar to the PHP one. The easiest thing you can do is do a test of the PHP version (running php.exe on the command line if you're on Windows) to see if it outputs the values you expect from a hash generated by the JS implementation. We need to know which implementation is broken basically, it might be the Go one (because of a mistake when porting it from PHP) or the JS one (for the same reason). Checking against the PHP version will show which one it is, if the PHP gives the same values as the Go one then the problem might be in the JS one, if the PHP version gives the same values as the JS one then the problem might be in the Go one. I hope that's clear enough :)

I'll check it. Thanks!

Results of Go implementation the same as in Perl, Python, Obj-C, but differ from the rest(PHP, javascript etc..). I found it at the main web site http://www.hashids.org. Maybe the problem in encoding?

@olebedev did you ever start updating to the newer algorithm?

@jpadilla, actually no. Unfortunately, I do not have much time, so I rollback js library to 0.1.3 version. And change alphabet to: xcS4F6h89aUbidefI7jkyunopqrsgCYE5GHTKLMtARXz, like in this Go library. This is work for me.

It's been updated to Hashids 1.0.0 now, I checked compatibility against the Javascript version and was okay.