code: def _CalculateHashDataStream(self, file_entry, data_stream_name):
      
      hash_context = hashlib.sha256()
  
      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 None
  
      if not file_object:
        return None
  
      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 None
  
      finally:
        file_object.close()
  
      return hash_context.hexdigest()
docs: Calculates a message digest hash of the data of the file entry.
  
      Args:
        file_entry (dfvfs.FileEntry): file entry.
        data_stream_name (str): name of the data stream.
  
      Returns:
        bytes: digest hash or None.