import uuid
import hashlib


def _create_token(user):
    """Create a unique token for a user.

    The token is created from the user id and a unique id generated
    from UUIDv4. Then both are hashed using MD5 digest algorithm.

    """
    _id = f"{user.id}-{str(uuid.uuid4())}"
    _hash = hashlib.md5(_id.encode('ascii'))
    return _hash.hexdigest()