code: def hash_contents(contents):
      
      assert isinstance(contents, GroupNode)
  
      result = hashlib.sha256()
  
      def _hash_int(value):
          result.update(struct.pack(">L", value))
  
      def _hash_str(string):
          assert isinstance(string, string_types)
          _hash_int(len(string))
          result.update(string.encode())
  
      def _hash_object(obj):
          _hash_str(obj.json_type)
          if isinstance(obj, (TableNode, FileNode)):
              hashes = obj.hashes
              _hash_int(len(hashes))
              for hval in hashes:
                  _hash_str(hval)
          elif isinstance(obj, GroupNode):
              children = obj.children
              _hash_int(len(children))
              for key, child in sorted(iteritems(children)):
                  _hash_str(key)
                  _hash_object(child)
          else:
              assert False, "Unexpected object: %r" % obj
  
          # Backward compatibility: only hash metadata_hash if it's present.
          if obj.metadata_hash is not None:
              _hash_str(obj.metadata_hash)
  
      _hash_object(contents)
  
      return result.hexdigest()
docs: Creates a hash of key names and hashes in a package dictionary.
  
      "contents" must be a GroupNode.