def _generateOpaque(self, nonce, clientip):
        """
        Generate an opaque to be returned to the client.  This is a unique
        string that can be returned to us and verified.
        """
        # Now, what we do is encode the nonce, client ip and a timestamp in the
        # opaque value with a suitable digest.
        now = intToBytes(int(self._getTime()))

        if not clientip:
            clientip = b''
        elif isinstance(clientip, unicode):
            clientip = clientip.encode('ascii')

        key = b",".join((nonce, clientip, now))
        digest = hexlify(md5(key + self.privateKey).digest())
        ekey = base64.b64encode(key)
        return b"-".join((digest, ekey.replace(b'\n', b'')))

        Generate an opaque to be returned to the client.  This is a unique
        string that can be returned to us and verified.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/cred/credentials.py