def test_encode_decode_base64_data(self): input_base64 = "VGhpcyBpcyBhIHRlc3QgbWVzc2FnZQo=" expected_output = base64.b64decode(input_base64) e = hiddenmsg.Encode(base64_data=input_base64) e.encode() d = hiddenmsg.Decode() self.assertEqual(d.get_data(), expected_output)
def test_encode_decode_4_single_byte_small_image(self): file_to_encode = "test/test-data-4.txt" data_to_encode = Helpers.file_to_data(file_to_encode) encode_images = ["test-images/test2/64.png"] e = hiddenmsg.Encode(data_file=file_to_encode, images_to_encode=encode_images) e.encode() d = hiddenmsg.Decode() self.assertEqual(d.get_data(), data_to_encode)
def test_encode_decode_3(self): file_to_encode = "test/test-data-3.txt" data_to_encode = Helpers.file_to_data(file_to_encode) encode_images = ["test-images/test2/huge.png"] e = hiddenmsg.Encode(data_file=file_to_encode, images_to_encode=encode_images) e.encode() d = hiddenmsg.Decode() self.assertEqual(d.get_data(), data_to_encode)
def test_encode_decode_7_specfic_dir(self): file_to_encode = "test/test-data-1.txt" data_to_encode = Helpers.file_to_data(file_to_encode) random_dir = Helpers.random_dir() e = hiddenmsg.Encode(data_file=file_to_encode, output_dir=random_dir) e.encode() d = hiddenmsg.Decode(images_dir=random_dir) self.assertEqual(d.get_data(), data_to_encode) Helpers.cleanup(random_dir)
def test_encode_decode_6_huge_random(self): file_to_encode = "test/1mb" data_to_encode = Helpers.file_to_data(file_to_encode) encode_images = [ "test-images/test6/1.jpg", "test-images/test6/2.jpg", "test-images/test6/3.jpg" ] e = hiddenmsg.Encode(data_file=file_to_encode, images_to_encode=encode_images) e.encode() d = hiddenmsg.Decode() self.assertEqual(d.get_data(), data_to_encode)
def test_encode_decode_limited_files(self): file_to_encode = "test/test-data-4.txt" data_to_encode = Helpers.file_to_data(file_to_encode) encode_images = [ "test-images/test6/1.jpg", "test-images/test6/2.jpg", "test-images/test6/3.jpg" ] e = hiddenmsg.Encode(data_file=file_to_encode, images_to_encode=encode_images) e.encode() d = hiddenmsg.Decode() self.assertEqual(d.get_data(), data_to_encode) self.assertTrue(len(glob.glob("encoded/*")) == 1)