    def _get_xsrf_token_id(self, handler):
        """Get contents for xsrf token for a given Handler

        This is the value to be encrypted & signed in the xsrf token
        """
        token = self._get_token_cookie(handler)
        session_id = self.get_session_id(handler)
        if token:
            token_hash = hashlib.sha256(token.encode("ascii", "replace")).hexdigest()
            if not session_id:
                session_id = _anonymous_xsrf_id(handler)
        else:
            token_hash = _anonymous_xsrf_id(handler)
        return f"{session_id}:{token_hash}".encode("ascii", "replace")
Get contents for xsrf token for a given Handler

This is the value to be encrypted & signed in the xsrf token
jupyterhub/services/auth.py