Get the MD5 hash of big files in Python
You need to read the file in chunks of suitable size: def md5_for_file(f, block_size=2**20): md5 = hashlib.md5() while True: data = f.read(block_size) if not data: break md5.update(data) return md5.digest() Note: Make sure you open your file with the ‘rb’ to the open – otherwise you will get the wrong result. So to do the whole … Read more