Crash Override
Crash Override

Reputation: 461

Hashids PHP and JS compatibility

Hello I'm trying to use the Hashids library (Website) in both of its versions, the PHP to generate server side hash and the JS to decode the given hash by the server. In both cases I'm using the same SALT.

PHP example:

$hashids = new Hashids\Hashids(SALT);
echo $hashids->encode(9); //prints GX

JS example:

var hashids = new Hashids(SALT);
return hashids.encode(9); //prints rE

I know I'm not decoding the PHP version with the JS version as mentioned but, the idea is to illustrate that they both give different results using the same SALT and ID.

Does anyone knows if its even possible to use hashids the way I'm doing it?

Thanks for your help

Upvotes: 0

Views: 1162

Answers (1)

ivanakimov
ivanakimov

Reputation: 157

You're probably using different library versions. Be sure that both PHP and JS are >1.0, and obviously print out the salt to be sure you're passing the right value.

Upvotes: 1

Related Questions