Пример #1
0
class Program:
    def __init__(self, source_filename):
        self._container = WavContainer(source_filename)

    def hide(self, data, output_file, bad_bits_num=1, order_num=0):
        with open(data, mode='rb') as f:
            bin_data = f.read()
        self._container.hide(bin_data, order_num, bad_bits_num)
        self._container.save_to_disk(output_file)

    def reveal(self, output_file, bad_bits_num=1, order_num=0):
        with open(output_file, mode="wb") as f:
            f.write(bytes(self._container.reveal(order_num, bad_bits_num)))

    def dump_hidden_data(self, bad_bits_num=1, order_num=0):
        try:
            dumper = Dumper()
            for line in dumper(self._container.reveal(order_num, bad_bits_num)):
                print(line)
        except BrokenPipeError:
            pass
Пример #2
0
 def test_example_work(self):
     p = WavContainer('container_1.wav')
     with open('data.txt', mode='rb') as f:
         data = f.read()
     p.hide(data, 2, 4)
     self.assertEqual(data, bytes(p.reveal(2, 4)))