1

I'd like to verify that a bunch of files (ten files or so) are unchanged. I thought it create a CRC/MD5 hash lists for these files and compare them with realtime hashes.

  1. What's more recommended? CRC or MD5?
  2. What is the right way to do it with Python?

Thanks.

iTayb
  • 12,373
  • 24
  • 81
  • 135
  • 1
    For 1. see: http://stackoverflow.com/questions/996843/when-is-crc-more-appropriate-to-use-than-md5-sha1 – Fox32 Mar 18 '11 at 17:22
  • 1
    For 2. see http://stackoverflow.com/questions/1131220/get-md5-hash-of-a-files-without-open-it-in-python – Fox32 Mar 18 '11 at 17:24

2 Answers2

2

CRC is simpler and faster, but only really designed to detect unintentional changes. MD5 is more secure.

Both are built into the Python Standard Library, check out hashlib for details.

http://docs.python.org/library/hashlib.html

lo5an
  • 76
  • 4
2

Also worth considering is SHA1 which is far more secure, but it really depend on why they may have been modified. CRC is good against random errors such as corruption in transit. MD5 and SHA1 are o do with intentional changes. SHA1 is better, but MD5 may be quicker.

theheadofabroom
  • 20,639
  • 5
  • 33
  • 65