def hashFile(file): block = 64 * 1024 hash = hashlib.sha256() with open(file, 'rb') as f: buf = f.read(block) while len(buf) > 0: hash.update(buf) buf = f.read(block) return hash.hexdigest()