

def _CalculateHashFileEntry(self, file_entry, data_stream_name):
    'Calculates a message digest hash of the data of the file entry.\n\n    Args:\n      file_entry: the file entry (instance of dfvfs.FileEntry).\n      data_stream_name: the data stream name.\n\n    Returns:\n      A binary string containing the digest hash or None.\n    '
    hash_context = hashlib.md5()
    try:
        file_object = file_entry.GetFileObject(data_stream_name=data_stream_name)
    except IOError as exception:
        logging.warning('Unable to open path specification:\n{0:s}with error: {1:s}'.format(file_entry.path_spec.comparable, exception))
        return
    if (not file_object):
        return
    try:
        data = file_object.read(self._READ_BUFFER_SIZE)
        while data:
            hash_context.update(data)
            data = file_object.read(self._READ_BUFFER_SIZE)
    except IOError as exception:
        logging.warning('Unable to read from path specification:\n{0:s}with error: {1:s}'.format(file_entry.path_spec.comparable, exception))
        return
    finally:
        file_object.close()
    return hash_context.hexdigest()

dataset/ETHPy150Open log2timeline/dfvfs/examples/recursive_hasher.py RecursiveHasher._CalculateHashFileEntry/original