pecl-xdiff is a php extension that creates and applies patches to both text and binary files.