import hashlib


def digest_file(filepath):
    """
    Get the MD5sum for a single file on disk.  Files are read in
    a memory-efficient fashion.

    Args:
        filepath (string): a string path to the file or folder to be tested
            or a list of files to be analyzed.

    Returns:
        An md5sum of the input file
    """

    block_size = 2**20
    file_handler = open(filepath, 'rb')
    file_md5 = hashlib.md5()
    for chunk in iter(lambda: file_handler.read(block_size), ''):
        file_md5.update(chunk)
    file_handler.close()

    return file_md5.hexdigest()