Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
    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"
Beispiel #4
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)
Beispiel #5
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)