Exemplo n.º 1
0
 def test_read_the_content(self):
     with open('filename.txt', 'w') as file:
         file.write('balblabla' * 5)
     lsb = LSBDecoder('filename.txt')
     buffer = bytearray(20)
     result = lsb._read_the_content(buffer, 10, 0, 1)
     os.remove('filename.txt')
     self.assertEqual(result, 10)
Exemplo n.º 2
0
 def test_read_the_hash(self):
     with open('filename.txt', 'w') as file:
         file.write('balblabla' * 5)
     lsb = LSBDecoder('filename.txt')
     result = lsb._read_the_hash(42, 0, 1)
     os.remove('filename.txt')
     self.assertIsInstance(result, tuple)
     self.assertEqual(result[0], 42)
     self.assertIsInstance(result[1], int)
Exemplo n.º 3
0
 def test_init(self):
     with open('filename.txt', 'w') as file:
         file.write('blablablabal' * 4)
     lsb = LSBDecoder('filename.txt', 0)
     os.remove('filename.txt')
     self.assertIsInstance(lsb.main_file, bytearray)
     self.assertEqual(lsb.index_of_start_of_data, 0)
     self.assertIsInstance(lsb.bits_per_sample, int)
Exemplo n.º 4
0
 def main(self):
     if self.parser.encode and self.parser.decode:
         raise Exception("This keys shouldn't be used at the same time")
     if self.parser.encode:
         file_path = ' '.join(self.parser.file)
         wav_path = ' '.join(self.parser.wav)
         if len(file_path) == 0 or len(wav_path) == 0:
             raise Exception('Not all arguments are specified. Try again!')
         lsb = LSBEncoder(file_path, wav_path)
         lsb.inscribe()
         return
     if self.parser.decode:
         wav_path = ' '.join(self.parser.wav)
         if len(wav_path) == 0:
             raise Exception('Not all arguments are specified. Try again!')
         lsb = LSBDecoder(wav_path)
         lsb.get_hidden_information()
 def main(self):
     parser = self.parse_args(sys.argv[1:])
     if parser.encode and parser.decode:
         raise Exception("This keys shouldn't be used at the same time")
     if parser.encode:
         files = parser.file
         wav_path = ' '.join(parser.wav)
         if len(files) == 0 or len(wav_path) == 0:
             raise Exception('Not all arguments are specified. Try again!')
         lsb = LSBEncoder(files, wav_path)
         lsb.inscribe()
         lsb.create_new_wav()
         return
     if parser.decode:
         wav_path = ' '.join(parser.wav)
         if len(wav_path) == 0:
             raise Exception('Not all arguments are specified. Try again!')
         lsb = LSBDecoder(wav_path)
         lsb.get_hidden_information()
Exemplo n.º 6
0
 def test_compare_of_checksum(self):
     try:
         LSBDecoder._compare_the_checksum(1, 0)
     except Exception:
         self.assertEqual(1, 1)