from typing import Union
import hashlib


def hashsum_str(x: Union[str, bytes], algo=None) -> str:
    """Compute the hash sum of the given string / bytes ; default algorithm is Sha1"""
    if algo is None:
        algo = hashlib.sha1
    elif isinstance(algo, str):
        algo = getattr(hashlib, algo)
    else:
        assert callable(algo), f'`algo` must be a hashlib algorithm name or a callable'

    if isinstance(x, str):
        x = x.encode('utf-8')
    return algo(x).hexdigest()