Пример #1
0
 def test_decode_message(self):
     msg = 'Test message'
     img = np.zeros((10, 10, 3), np.uint8)
     encrypter = Encrypter(img, msg)
     encrypter.encode()
     decrypter = Decrypter(encrypter.img)
     result = decrypter.decode_message()
     self.assertEqual(result, msg)
Пример #2
0
    def test_end_message_found(self):
        sample_img = np.zeros((5, 5, 3), np.uint8)
        decrypter = Decrypter(sample_img)
        msg = '0110001001010011'  # just random
        self.assertFalse(decrypter.end_message_found(msg))
        msg = 'test' + Decrypter.ENDMSG_CODE
        bin_msg = ''
        for x in msg:
            binary = Encrypter.convert_to_bytes_string(x)
            bin_msg += binary

        self.assertTrue(decrypter.end_message_found(bin_msg[-64:]))
Пример #3
0
 def test_create_bytes_list(self):
     a = '01100001'
     x = '01111000'
     ax = a + x
     result = Decrypter.create_bytes_list(ax)
     self.assertEqual(len(result), 2)
     for r in result:
         self.assertIn(chr(int(r, 2)), 'ax')
Пример #4
0
 def test_bytes_list_to_string(self):
     a = '0b01100001'
     x = '0b01111000'
     ax = [a, x]
     result = Decrypter.bytes_list_to_string(ax)
     self.assertEqual(result, 'ax')