def sign(self, data, b64=True):
        """Sign data with the private key and return the signed data.

        The signed data will be Base64 encoded if b64 is True.
        """
        padder = padding.PKCS1v15()
        signer = self.private_key.signer(padder, None)
        if not isinstance(data, six.binary_type):
            data = data.encode('utf_8')
        signer.update(data)
        signed = signer.finalize()
        if b64:
            signed = base64.b64encode(signed)
        return signed
Sign data with the private key and return the signed data.

        The signed data will be Base64 encoded if b64 is True.