from typing import Union
import hashlib


def sha1(data: Union[bytes, str]) -> str:
    """
    Generate hexdigest representation of SHA-1 hash of `data`.

    This can be used to compute the "fileID" for a given `domain` and `relativePath`:
        fileID = sha1(f"{domain}-{relativePath}")
    """
    if isinstance(data, str):
        data = data.encode()
    hashobj = hashlib.sha1()
    hashobj.update(data)
    return hashobj.hexdigest()