|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-11 11:07 UTC] tony2001@php.net
[2008-08-18 14:33 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
Description: ------------ When I use dechex() to convert a crc32(), and when I directly use hash("crc32b", ...), I do not get the same output. In particular, the endianness of the hash() output seems inverted. In other words: the output of crc32() seems to be correct in its integer representation (I compared it with Python implementation), but converting it to hexadecimal (with dechex() or with any calculator) produces a hex string inverted in its endianness respect to the output of hash('crc32b', ...) with the same input. Reproduce code: --------------- printf("dechex(crc32(\"AAAAAAAA\")): ". dechex(crc32("AAAAAAAA")). "<br><br>"); printf("hash(\"crc32b\",\"AAAAAAAA\"): " .hash("crc32b", "AAAAAAAA") ."<br>"); Expected result: ---------------- dechex(crc32("AAAAAAAA")): 79b71c0a hash("crc32b","AAAAAAAA"): 79b71c0a (or dechex(crc32("AAAAAAAA")): 0a1cb779 hash("crc32b","AAAAAAAA"): 0a1cb779 I think the first two are the right ones) Actual result: -------------- dechex(crc32("AAAAAAAA")): 79b71c0a hash("crc32b","AAAAAAAA"): 0a1cb779 Please note that the difference is only in the bytes order. "0a-1c-b7-79" is like "79-b7-1c-0a" with inverted endianness, while both lines should output the same values despite different architectures.