开发者

Verify that files aren't modified

I'd like to verify that a b开发者_运维问答unch 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜