def encrypt(self, data): """ Encrypt the data with self.pub and return the ciphertext. @raises Exception: The encryption failed. """ assert self.pub, "Attempt to encrypt without key." cryptor = Cryptor(pubkey_hex=self.pub) return cryptor.encrypt(data)