Friday 15 February 2013

Return hexidecimal differences in binary files with PHP -



Return hexidecimal differences in binary files with PHP -

i've read , tried every reply here, yet seem apply strings in non-binary formats. i'm trying compare differences in binary files , homecoming in format such this:

[file1] -0001010: ac 0f 00 00 01 00 00 00 48 65 6c 6c 6f 2c 20 77 ........hello, w [file2] +0001010: ac 0f 00 00 01 00 00 00 48 75 6c 6c 6f 2c 20 77 ........hullo, w

xdiff works fine creating bdiff patches , patching file - i'm looking illustrate differences.

$one = 'one'; // original file $two = 'two'; // updated file $pat = 'dif'; // bdiff patch $new = 'new'; // new destfile xdiff_file_diff_binary($one, $two, $pat); xdiff_file_patch_binary($one, $pat, $new); $diff = xdiff_file_diff($one, $two, 1); if (is_file($diff)) { echo "differences:\n"; // result = 1 echo $diff; }

maybe xdiff isn't right extension using this? i'm not sure.

sound big pain in butt in php, might suggest next bash one-liner?

diff <(hexdump -c file1) <(hexdump -c file2)

output:

10c10 < 00000090 35 35 61 34 32 62 62 31 30 33 31 62 38 38 39 34 |55a42bb1031b8894| --- > 00000090 35 35 61 34 32 62 62 31 30 33 31 61 38 38 39 34 |55a42bb1031a8894|

and can mess options diff , hexdump.

php binary hex diff

No comments:

Post a Comment