@@ -0,0 +1,2852 @@
+from random import choice%0Aimport numpy as np%0Aimport os%0Afrom PIL import Image%0Afrom stego_lsb.bit_manipulation import roundup%0Afrom stego_lsb.LSBSteg import hide_data, recover_data, bytes_in_max_file_size%0Aimport string%0Aimport unittest%0A%0Aimport logging%0A%0A%0Aclass TestLSBSteg(unittest.TestCase):%0A    def write_random_image(self, filename, width, height):%0A        image_data = np.random.randint(0, 256, size=(height, width, 3), dtype=np.uint8)%0A        image = Image.fromarray(image_data)%0A        image.save(filename)%0A%0A    def write_random_file(self, filename, num_bytes):%0A        with open(filename, %22wb%22) as file:%0A            file.write(os.urandom(num_bytes))%0A%0A    def test_random_interleaving(self, num_trials=64, filename_length=5):%0A        filename = %22%22.join(%0A            choice(string.ascii_lowercase) for _ in range(filename_length)%0A        )%0A        png_input_filename = filename + %22.png%22%0A        payload_input_filename = filename + %22.txt%22%0A        png_output_filename = filename + %22_steg.png%22%0A        payload_output_filename = filename + %22_recovered.txt%22%0A%0A        np.random.seed(0)%0A        for _ in range(num_trials):%0A            width = np.random.randint(1, 256)%0A            height = np.random.randint(1, 256)%0A            num_lsb = np.random.randint(1, 9)%0A%0A            file_size_tag_length = roundup(%0A                int(3 * width * height * num_lsb).bit_length() / 8%0A            )%0A            payload_len = (3 * width * height * num_lsb - 8 * file_size_tag_length) // 8%0A%0A            if payload_len %3C 0:%0A                continue%0A%0A            self.write_random_image(png_input_filename, width=width, height=height)%0A            self.write_random_file(payload_input_filename, num_bytes=payload_len)%0A%0A            try:%0A                hide_data(%0A                    png_input_filename,%0A                    payload_input_filename,%0A                    png_output_filename,%0A                    num_lsb,%0A                    compression_level=1,%0A                )%0A                recover_data(png_output_filename, payload_output_filename, num_lsb)%0A            except ValueError as e:%0A                os.remove(png_input_filename)%0A                os.remove(payload_input_filename)%0A                os.remove(png_output_filename)%0A                os.remove(payload_output_filename)%0A                raise e%0A%0A            with open(payload_input_filename, %22rb%22) as input_file, open(%0A                payload_output_filename, %22rb%22%0A            ) as output_file:%0A                input_payload_data = input_file.read()%0A                output_payload_data = output_file.read()%0A%0A            os.remove(png_input_filename)%0A            os.remove(payload_input_filename)%0A            os.remove(png_output_filename)%0A            os.remove(payload_output_filename)%0A%0A            self.assertEqual(input_payload_data, output_payload_data)%0A%0A%0Aif __name__ == %22__main__%22:%0A    unittest.main()%0A

Add simple LSBSteg tests