def test_decrypts_message_with_more_than_ten_padded_characters(self): sixteen_char_message = '{ a }' + chr(11) * 11 encrypted_message = encrypt_string(sixteen_char_message, self.__key) decrypted_message = decrypt_message(encrypted_message, self.__key) self.assertEqual(decrypted_message, '{ a }')
def test_decrypts_message_with_some_padding(self): sixteen_char_message = '{ abcdefghij }' + chr(2) * 2 encrypted_message = encrypt_string(sixteen_char_message, self.__key) decrypted_message = decrypt_message(encrypted_message, self.__key) self.assertEqual(decrypted_message, '{ abcdefghij }')
def test_decrypts_message_with_full_final_block_padding(self): sixteen_char_message = '{ abcdefghijkl }' encrypted_message = encrypt_string(sixteen_char_message, self.__key) decrypted_message = decrypt_message(encrypted_message, self.__key) self.assertEqual(decrypted_message, '{ abcdefghijkl }')
def test_decrypts_message_with_more_than_ten_padded_characters(self): five_char_message = '{ a }' encrypted_message = encrypt_string(five_char_message, self.__key) decrypted_message = decrypt_message(encrypted_message, self.__key) self.assertEqual(decrypted_message, '{ a }')
def test_decrypts_message_with_full_final_block_padding(self): # PKCS5 Padding uses a block of chr(0) to indicate that there was a full # block of bytes in the previous block sixteen_char_message_with_padding = '{ abcdefghijkl }' + chr(16) * 16 encrypted_message = encrypt_string(sixteen_char_message_with_padding, self.__key) decrypted_message = decrypt_message(encrypted_message, self.__key) self.assertEqual(decrypted_message, '{ abcdefghijkl }')
def __encrypt_and_send_to_sqs(self, messages): message_ids = [] for message in messages: encrypted_message = encrypt_string(message, ENCRYPTION_KEY) response = self.__sqs_client.send_message( QueueUrl=self.__queue_url, MessageBody=encrypted_message, DelaySeconds=0) message_ids.append(response['MessageId']) return message_ids
def __encrypt_and_send_to_sqs(self, messages): for message in messages: encrypted_message = encrypt_string(pad(message), ENCRYPTION_KEY) self.__sqs_client.send_message(QueueUrl=self.__queue_url, MessageBody=encrypted_message, DelaySeconds=0)