hexdump vs actual file contents
Solution 1:
The difference is big-endian vs. little-endian order.
Start with the first four bytes of hexdump output: ac5a 5afb
. Now switch the byte order to get:
5aac fb5a
Compare this with the PHP output:
5aac fb5a
They match.
By default, BSD hexdump
displays output based on the machine's endianness. If you don't want that, you can specify the -C
option to get output byte-by-byte rather word-by-word:
$ hexdump filename.txt
0000000 ac5a 5afb c08d 5d15 26d0 2491 e8c9 8917
0000010
$ hexdump -C filename.txt
00000000 5a ac fb 5a 8d c0 15 5d d0 26 91 24 c9 e8 17 89 |Z..Z...].&.$....|
00000010