Home:ALL Converter>Hashids PHP and JS compatibility

Hashids PHP and JS compatibility

Ask Time:2015-03-20T01:16:18         Author:Crash Override

Json Formatter

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

Author:Crash Override,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29150973/hashids-php-and-js-compatibility
yy