in reply to Re: MD 5 hash comparison/checker
in thread MD 5 hash comparison/checker

Um... okay, if it's just a question of comparing one file to one other file to determine "same" or "different", a byte-for-byte comparison like you suggest certainly makes the most sense. Good call. (Update: Of course, just using the *n*x "cmp" utility will be a lot easier/quicker.)

But if it were a case of looking for duplicates among a large set of files, using the md5 signatures of the files (in combination with file byte counts) will save a lot of time. (I don't know if the OP represents this sort of "XY Problem" -- talking about comparing two files when the task is actually bigger than that -- but it's worth mentioning in any case.)

Replies are listed 'Best First'.
Re^3: MD 5 hash comparison/checker
by ikegami (Patriarch) on May 07, 2010 at 03:59 UTC

    (Update: Of course, just using the *n*x "cmp" utility will be a lot easier/quicker.)

    He's on Windows (or else use digest::MD5; wouldn't have worked), and it was faster for me to type up the program than two figure out the dos command :)

    But if it were a case of looking for duplicates among a large set of files

    Indeed, but there's no evidence of that. That's why I asked and suggested an alternative.

      Actually, Digest::MD5 works on OS X also:
      $ perl -MDigest::Md5 -e '' $ perl -MDigest::MD5 -e '' $
      The weird mix of "sometimes case-sensitive, sometimes case-insensitive" in OS X is one of my bigger pet peeves about it in theory, but, in practice, it's only bitten me once (when I created two files in the same directory whose names differed only in case and I attempted to delete one, but ended up deleting both).

      Based on other responses by the OP, it's clear that he is using Windows, so your conclusion is correct, even if it's based on a data point which doesn't necessarily support it.

        Thanks, I didn't know