def getResults(self, key, rounds, data, array):
        """
        Iterate through many random permutations of
        masking and conduct DES for certain number of rounds
        Adds to list of results if similar.
        """

        counter_without_result = 0
        results = {}
        while True:

            if counter_without_result > 2**17:
                break

            curr_len = len(results)

            num1, num2 = self._get_xor_hex(array, results)
            hex_value = num1 + num2

            new_data = self.bitwise_xor(data, hex_value)
            des_ = DES(key, new_data, self.rounds, self.mode)

            new_rounds = des_._encrypt()

            results = self.check_similarity(results, rounds, new_rounds,
                                            hex_value)

            if len(results) > curr_len:

                counter_without_result = 0
            else:
                counter_without_result += 1

        return results
    def main(self):

        permutations = 2**25
        array = []
        for i in range(permutations):
            if str(bin(i)).count('1') < 4:
                array.append(i)
        print(array[:10])
        num_results = 0

        while True:

            key, data = self.generate()

            des = DES(key, data, self.rounds, self.mode)
            rounds = des._encrypt()

            results = self.getResults(key, rounds, data, array)

            sim_results = self.getXORSimiarlity(results)

            if len(sim_results) != 0:

                with open("S5DESTriples" + data, 'a') \
                        as file_out:

                    for i in range(len(sim_results)):

                        if i % 2 == 0:
                            num_results += 1
                            print("S5DES:" + str(num_results))
                            initial_ = key + "\t" + self.mode + '\t' \
                                       + data[:8] + '\t' + data[8:] + '\t'
                            line_w_tabs = "\t".join(rounds) + '\n'
                            file_out.write(initial_)
                            file_out.write(line_w_tabs)


                        initial_ = key + "\t" + self.mode + '\t' \
                                   + sim_results[i][0][:8] + '\t'\
                                   + sim_results[i][0][8:] + '\t'
                        line_w_tabs = "\t".join(sim_results[i][1]) + '\n'
                        file_out.write(initial_)
                        file_out.write(line_w_tabs)
                        end_time = time.time()
                        self.timearray.append(end_time - self.start)