def decrypt_data(channel_cipher, data): if not isinstance(data, CipherData): return decrypted_data = channel_cipher.decrypt(data.buffer) decrypted_typed_buffer = TypedBuffer(decrypted_data, data.type) return decrypted_typed_buffer.decode()
def decrypt_data(channel_cipher, data): if not isinstance(data, CipherData): return decrypted_data = channel_cipher.decrypt(data.buffer) decrypted_typed_buffer = TypedBuffer(decrypted_data, data.type) return decrypted_typed_buffer.decode()
def decrypt(self, channel_cipher): if not isinstance(self.data, CipherData): return decrypted_data = channel_cipher.decrypt(self.data.buffer) decrypted_typed_buffer = TypedBuffer(decrypted_data, self.data.type) self.__data = decrypted_typed_buffer.decode()
def encrypt(self, channel_cipher): if isinstance(self.data, CipherData): return typed_data = TypedBuffer.from_obj(self.data) if typed_data.buffer is None: return True encrypted_data = channel_cipher.encrypt(typed_data.buffer) self.__data = CipherData(encrypted_data, typed_data.type)
def encrypt(self, channel_cipher): if isinstance(self.data, CipherData): return elif isinstance(self.data, six.text_type): self._encoding_array.append('utf-8') if isinstance(self.data, dict) or isinstance(self.data, list): self._encoding_array.append('json') self._encoding_array.append('utf-8') typed_data = TypedBuffer.from_obj(self.data) if typed_data.buffer is None: return True encrypted_data = channel_cipher.encrypt(typed_data.buffer) self.__data = CipherData(encrypted_data, typed_data.type, cipher_type=channel_cipher.cipher_type)
def encrypt(self, channel_cipher): if isinstance(self.data, CipherData): return elif isinstance(self.data, six.text_type): self._encoding_array.append('utf-8') if isinstance(self.data, dict) or isinstance(self.data, list): self._encoding_array.append('json') self._encoding_array.append('utf-8') typed_data = TypedBuffer.from_obj(self.data) if typed_data.buffer is None: return True encrypted_data = channel_cipher.encrypt(typed_data.buffer) self.__data = CipherData(encrypted_data, typed_data.type, cipher_type=channel_cipher.cipher_type)