tuupola / base85

Base85 encoder and decoder for arbitrary data
MIT License
27 stars 3 forks source link

Returns a different result on a 32-bit platform vs 64-bit #25

Open romanrm opened 6 months ago

romanrm commented 6 months ago

With a code like this:

echo Tuupola\Base85Proxy::encode(md5("test", true)), "\n";

amd64:

$'/lH7Np6%b2,mG-7?1o

armv7el:

$'/lH7Np6%epLbF-7?1o

PHP 7.4 on both.

-- Just reported a similar bug to another base85 package: https://github.com/scottchiefbaker/php-base85/issues/2 that one has a more severe problem. "unpack" is problematic on 32-bit vs 64-bit, yours almost works, but also couldn't escape it.

tuupola commented 6 months ago

I wonder which result is correct. I would guess the 64-bit one.

tuupola commented 6 months ago

Might also be related to this: https://github.com/tuupola/base85/issues/7

romanrm commented 6 months ago

Yes the 64-bit value is correct. See some investigation on the other bug report, and some suggestions in PHP doc comments: https://github.com/scottchiefbaker/php-base85/issues/2#issuecomment-2038821556 https://www.php.net/manual/en/function.unpack.php#106041