예제 #1
0
파일: integration.py 프로젝트: qll/shit
 def test_encode_decode_msg_from_bit(self):
     IMG = scipy.misc.lena()
     MSG = 'This test works well'
     # test with lsb
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=7)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=7)
     self.assertEqual(MSG, msg)
     # test with bit in between
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=4)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=4)
     self.assertEqual(MSG, msg)
     # test with msb
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=0)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=0)
     self.assertEqual(MSG, msg)
예제 #2
0
파일: integration.py 프로젝트: toanou/shit
 def test_encode_decode_msg_from_bit(self):
     IMG = scipy.misc.lena()
     MSG = 'This test works well'
     # test with lsb
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=7)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=7)
     self.assertEqual(MSG, msg)
     # test with bit in between
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=4)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=4)
     self.assertEqual(MSG, msg)
     # test with msb
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG, stegobit=0)
     msg = retrieve.decode_msg_from_bit(img_array=stego_img, stegobit=0)
     self.assertEqual(MSG, msg)
예제 #3
0
파일: integration.py 프로젝트: qll/shit
 def test_constructed_strings(self):
     IMG = scipy.misc.lena()
     MSG1 = 'Steganography has no chance'
     MSG2 = 'Really really no chance'
     # first, hide two messages in the same image
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG1, stegobit=7)
     stego_img = hide.encode_msg_in_bit(img_array=stego_img, msg=MSG2,
                                        stegobit=5)
     # then, check if we get it back out
     msgs1 = analyse.constructed_strings(img_array=stego_img, threshold=4)
     msgs1 = list(msgs1)
     self.assertIn(MSG1, msgs1)
     self.assertIn(MSG2, msgs1)
     # test with a higher threshold (fewer garbage strings)
     msgs2 = analyse.constructed_strings(img_array=stego_img, threshold=14)
     msgs2 = list(msgs2)
     self.assertIn(MSG1, msgs2)
     self.assertIn(MSG2, msgs2)
     # we should get a lot fewer results for a higher threshold
     self.assertTrue(len(msgs1) > len(msgs2))
예제 #4
0
파일: integration.py 프로젝트: toanou/shit
 def test_constructed_strings(self):
     IMG = scipy.misc.lena()
     MSG1 = 'Steganography has no chance'
     MSG2 = 'Really really no chance'
     # first, hide two messages in the same image
     stego_img = hide.encode_msg_in_bit(img_array=IMG, msg=MSG1, stegobit=7)
     stego_img = hide.encode_msg_in_bit(img_array=stego_img,
                                        msg=MSG2,
                                        stegobit=5)
     # then, check if we get it back out
     msgs1 = analyse.constructed_strings(img_array=stego_img, threshold=4)
     msgs1 = list(msgs1)
     self.assertIn(MSG1, msgs1)
     self.assertIn(MSG2, msgs1)
     # test with a higher threshold (fewer garbage strings)
     msgs2 = analyse.constructed_strings(img_array=stego_img, threshold=14)
     msgs2 = list(msgs2)
     self.assertIn(MSG1, msgs2)
     self.assertIn(MSG2, msgs2)
     # we should get a lot fewer results for a higher threshold
     self.assertTrue(len(msgs1) > len(msgs2))
예제 #5
0
파일: test_hide.py 프로젝트: qll/shit
 def test_msg_too_long_for_image(self):
     with self.assertRaises(AssertionError):
         hide.encode_msg_in_bit(img_array=lena(), msg="A" * (lena().size + 1), stegobit=3)