예제 #1
0
    public List <BitArray> Get_bit_block(int number)
    {
        List <BitArray> bit_block = new List <BitArray>();
        BitArray        bits      = new BitArray(Static_Data.Get_segment_size());

        int counter = 0;

        for (int i = Static_Data.Get_double_segment_size() * number; i < Static_Data.Get_double_segment_size() * number + Static_Data.Get_segment_size(); i++)
        {
            bits[counter] = work_bits[i];

            counter++;
        }

        bit_block.Add(bits);
        bits    = new BitArray(Static_Data.Get_segment_size());
        counter = 0;

        for (int i = Static_Data.Get_double_segment_size() * number + Static_Data.Get_segment_size(); i < Static_Data.Get_double_segment_size() * (number + 1); i++)
        {
            bits[counter] = work_bits[i];

            counter++;
        }

        bit_block.Add(bits);

        return(bit_block);
    }
예제 #2
0
    private BitArray Calculate_block()
    {
        var      list_block = laundry_data.Get_bit_block(current_block);
        BitArray block1     = list_block[0];
        BitArray block2     = list_block[1];

        BitArray block2t = new BitArray(block2.Length);

        for (int i = 0; i < block2.Length; i++)
        {
            block2t[i] = block2[i];

            Debug.Log(block2[i] + " " + block2t[i]);
        }

        BitArray double_block = new BitArray(Static_Data.Get_double_segment_size());

        // === FUNKCJE + KLUCZ ===

        int[] perm_tab = { 16,  7, 20, 21, 29, 12, 28, 17,  1, 15, 23, 26,
                           5,  18, 31, 10,  2,  8, 24, 14, 32, 27,  3,  9,19, 13, 30, 6,
                           22, 11,  4, 25 };



        if (picked_functions.Contains(Math_Functions.F1))
        {
            for (int i = 0; i < Static_Data.Get_segment_size(); i++)
            {
                // Debug.Log(block2[i]);



                block2[i] = block2[perm_tab[i] - 1];
            }
        }

        if (picked_functions.Contains(Math_Functions.F2))
        {
        }

        if (picked_functions.Contains(Math_Functions.F3))
        {
        }

        if (picked_functions.Contains(Math_Functions.F4))
        {
        }



        // === XOR ===

        for (int i = 0; i < block1.Length; i++)
        {
            block2[i] = block1[i] ^ block2[i];
        }

        // === ZAMIANA MIEJSCAMI

        for (int i = 0; i < Static_Data.Get_segment_size(); i++)
        {
            //Debug.Log(block2t[i]);

            double_block[i] = block2t[i];
        }

        int counter = 0;

        for (int i = Static_Data.Get_segment_size(); i < double_block.Length; i++)
        {
            double_block[i] = block2[counter];
            counter++;
        }

        // === DOPISANIE GOTOWEGO BLOKU DO PELNIEJ WIADOMOSCI ===

        laundry_data.Set_bit_block(double_block, current_block);

        current_block++;

        if (current_block >= number_of_blocks)
        {
            end_of_blocks = true;
        }

        return(double_block);
    }