import hashlib
import base64


def get_unique_torrent_id(infohash: str, add_date: int) -> str:
    """This function creates a unique string based on an instance of a torrent in transmission.
    This takes into account the infohash and added time so we can track the same torrent as separate
    instances if a torrent was removed then re-added. This way we can track their stats separately."""
    hash_data = f"{infohash}{add_date}".encode("ascii")
    hash_digest = hashlib.blake2b(hash_data, digest_size=12).digest()
    # turn the digest bytes back into a string via base64
    return base64.b64encode(hash_digest).decode("ascii")