code: def hashed_download(url, temp, digest):
      
      # Based on pip 1.4.1's URLOpener but with cert verification removed
      def opener():
          opener = build_opener(HTTPSHandler())
          # Strip out HTTPHandler to prevent MITM spoof:
          for handler in opener.handlers:
              if isinstance(handler, HTTPHandler):
                  opener.handlers.remove(handler)
          return opener
  
      def read_chunks(response, chunk_size):
          while True:
              chunk = response.read(chunk_size)
              if not chunk:
                  break
              yield chunk
  
      response = opener().open(url)
      path = join(temp, urlparse(url).path.split('/')[-1])
      actual_hash = sha256()
      with open(path, 'wb') as file:
          for chunk in read_chunks(response, 4096):
              file.write(chunk)
              actual_hash.update(chunk)
  
      actual_digest = actual_hash.hexdigest()
      if actual_digest != digest:
          raise HashError(url, path, actual_digest, digest)
      return path
docs: Download ``url`` to ``temp``, make sure it has the SHA-256 ``digest``,
      and return its path.