dig_123
dig_123

Reputation: 2358

What is the difference between md5sum and cksum

Can someone explain what is the difference between md5sum and cksum, when I compare 2 binary files.

One difference I know is cksum gives the number of "bytes" also along with the checksum value, which md5sum doesn't give.

But my question is to compare 2 binary files, I can chose to use any of these at my will, or they have any specific purposes as well, for specific situations.

Thanks in advance for your help

Upvotes: 7

Views: 8544

Answers (1)

mivk
mivk

Reputation: 14824

If all you want is to check if 2 specific files are different or not, use cmp FILE1 FILE2. It will stop at the first difference encountered, so you don't lose time calculating checksums for the entire file.

If you do need a full checksum :

  • cksum does a 32 bit ckecksum (CRC-32), while md5sum does a "more reliable" 128 bit checksum.
  • cksum being simpler, it may be faster in some cases, but it may also not be the case because md5sum has been highly optimized for speed.
  • cksum is part of POSIX, and may be present on some systems where md5sum is not.

Note that on Mac OS X, md5sum is not installed by default, but there is md5. The output of md5 -r is in the same format as md5sum.

Upvotes: 6

Related Questions