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)
def test_encode(self): # Just one character because encoding requires 32 bits for # input end message text = 'x' # 01111000 - (1, 3, 2, 0) (bit pairs decimal repr) img = np.zeros((6, 6, 1), np.uint8) obj = Encrypter(img, text) obj.encode() self.assertEqual(img.item(0, 0, 0), 1) self.assertEqual(img[0][1], 3) self.assertEqual(img[0][2], 2) self.assertEqual(img[0][3], 0)