def checksum(file_path, hash_type='<STR_LIT>', block_size=<NUM_LIT>):
if hash_type == '<STR_LIT>':<EOL><INDENT>hash_ = hashlib.md5()<EOL><DEDENT>elif hash_type == '<STR_LIT>':<EOL><INDENT>hash_ = hashlib.sha256()<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>.format(hash_type)<EOL>)<EOL><DEDENT>with open(file_path, '<STR_LIT:rb>') as f:<EOL><INDENT>for block in iter(lambda: f.read(block_size), b'<STR_LIT>'):<EOL><INDENT>hash_.update(block)<EOL><DEDENT><DEDENT>return hash_.hexdigest()<EOL>
Returns either the md5 or sha256 hash of a file at `file_path`.

    md5 is the default hash_type as it is faster than sha256

    The default block size is 64 kb, which appears to be one of a few command
    choices according to https://stackoverflow.com/a/44873382/2680. The code
    below is an extension of the example presented in that post.