def build_data(self): if self._use_post is True: cipher = self.pubnub.config.cipher_key if cipher is not None: return '"' + pn_crypto.encrypt(cipher, utils.write_value_as_string(self._message)) + '"' else: return utils.write_value_as_string(self._message) else: return None
def test_decode_aes(self): hey = """ dfjn t564 sdfhp\n """ assert crypto.decrypt(key, crypto.encrypt(key, hey)) == hey assert crypto.decrypt(key, todecode) == "hey-0"
def build_path(self): if self._use_post: return Publish.PUBLISH_POST_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, self._channel, 0) else: cipher = self.pubnub.config.cipher_key stringified_message = utils.write_value_as_string(self._message) if cipher is not None: stringified_message = '"' + pn_crypto.encrypt(cipher, stringified_message) + '"' stringified_message = utils.url_encode(stringified_message) return Publish.PUBLISH_GET_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, self._channel, 0, stringified_message)