how to get correct checksum md5 for a several parts downloaded file?

Viewed 14

I've written a program in python that downloads a file and if it finishes before complete download, it can resume the rest. The problem is that the checksum when it downloads the file without any interrupts is different to the checksum when it downloads the file in several parts. how can I fix this to get the same checksum in every situations.

This is my code for getting checksum:

import hashlib
import checksumdir
    
def _get_directory_checksum(folder: pathlib.Path) -> str:
        if folder.is_dir():
            return checksumdir.dirhash(str(folder), 'md5')
        else:
            return checksumdir._filehash(str(folder), hashlib.md5)
0 Answers
Related