code: def hash_from_algo(algo):
      
  
      try:
          enabled, (fun_name, fun_args, fun_kwargs) = _HASH_ALGO_MAP[algo]
      except KeyError:
          raise NotImplementedError(
              "hash algorithm {!r} unknown".format(algo)
          ) from None
  
      if not enabled:
          raise ValueError(
              "support of {} in XMPP is forbidden".format(algo)
          )
  
      try:
          fun = getattr(hashlib, fun_name)
      except AttributeError as exc:
          raise NotImplementedError(
              "{} not supported by hashlib".format(algo)
          ) from exc
  
      return fun(*fun_args, **fun_kwargs)
docs: Return a :mod:`hashlib` hash given the :xep:`300` `algo`.
  
      :param algo: The algorithm identifier as defined in :xep:`300`.
      :type algo: :class:`str`
      :raises NotImplementedError: if the hash algortihm is not supported by
          :mod:`hashlib`.
      :raises ValueError: if the hash algorithm MUST NOT be supported.
      :return: A hash object from :mod:`hashlib` or compatible.
  
      If the `algo` is not supported by the :mod:`hashlib` module,
      :class:`NotImplementedError` is raised.