import hmac


def compute_signature(payload: bytes, secret: bytes, algo: str = 'sha256') -> str:
  """
  Computes the HMAC signature of *payload* given the specified *secret* and the given hashing *algo*.

  # Parmeters
  payload: The payload for which the signature should be computed.
  secret: The secret string that is used in conjunction to generate the signature.
  algo: The hash algorithm to use, must be `sha1` or `sha256`.
  """

  if algo not in ('sha1', 'sha256'):
    raise ValueError(f'algo must be {{sha1, sha256}}, got {algo!r}')
  return f'{algo}=' + hmac.new(secret, payload, algo).hexdigest()