Peter Krauss Peter Krauss - 1 month ago 4
PHP Question

Equivalent build-in functions not outputs same values

PHP is known to offer many build-in functions, that do the same thing... This is perhaps more one, but strange,

echo "\nhash = ".hash('crc32', 'My Test');
// as guide say "outputs lowercase hexits", hash = c6fd93c1
echo "\nhash from raw = ".bin2hex( hash('crc32','My Test',true) );
// confirm that "hexits" are hexadecimals, = c6fd93c1
echo "\ncrc32 = ".base_convert( crc32('My Test') , 10, 16);
// crc32 = c55b6e4 !! not the same

there are more than one "standard CRC32"? Why not show the same value?


crc32 function computes same hash as hash with crc32b does.

$ php -r 'echo hash("crc32b", "My Test");' ;echo