import hashlib


def checksum(filepath=None, content=None, hash_fn=hashlib.sha1):
    """
    Compute the checksum of given file, `filepath`

    :param filepath: Absolute path to the file to compuste its checksum
    :param content: a (unicode) str gives the content of the file
    :param hash_fn: Hash algorithm to compute the checksum

    :return: A str gives the checksum value of the given file's content
    """
    if content is None:
        if filepath is None:
            raise ValueError("Either `filepath` or `content` must be given!")

        content = open(filepath).read()

    # content (unicode str) must be encoded to the byte data.
    return hash_fn(content.encode("utf-8")).hexdigest()