Beispiel #1
0
def more_travel(array):
    """
    """
    if is_bijective(array):
        all_perms = list(per(range(8)))
        for var in range(64):
            array_mod = []
            for num in range(32):
                array_mod, graph = substitution(
                    all_perms, array, array_mod, num)
                graphs.append(graph)
            nn_array_mod = value_nonl(array_mod)
            print(var, nn_array_mod)
            if nn_array_mod > limit:
                non_sbox[nn_array_mod] = [array_mod, graphs]
                print(value_nonl(array), nn_array_mod)
    else:
        print('Is not bijective!')
    return 1
Beispiel #2
0
def selected_travel(nodes):
    """
    """
    # PHEW! Bug fix!!!!!
    array = list(sbox)
    indices = {}
    # get indices of all the above nodes
    for node in nodes:
        indices[array.index(node)] = node
    maps, num = {}, 0
    for node in indices:
        maps[num] = node
        num += 1
    all_perms = list(per(range(8)))
    cost_path, paths, graph = travelling(all_perms)
    min_path = paths[min(cost_path)]
    new_mapping = {}
    for num in range(len(min_path) - 1):
        new_mapping[maps[num]] = indices[maps[min_path[num]]]
    # Substitute! the sequence
    for node in new_mapping:
        array[node] = new_mapping[node]
    return array, graph