예제 #1
0
    public void Ready_up_encryption()
    {
        message = laundry_data.Get_data();
        Russian();

        cipher_canvas.gameObject.SetActive(true);
        left_main.SetActive(true);
        left_txt.SetActive(false);
        left_img.SetActive(false);

        work_bits            = laundry_data.Get_raw_bits();
        picked_functions     = laundry_data.Get_picked_functions();
        number_of_iterations = laundry_data.Get_iterations();
        current_iteration    = 0;
        end_of_iteration     = false;
        number_of_blocks     = work_bits.Length / Static_Data.Get_double_segment_size();
        current_block        = 0;
        end_of_blocks        = false;
        cipher_state         = Cipher_State.Encryption;
        cipher_type          = laundry_data.Get_cipher_type();
        Set_current(work_bits, full_sqtr_size);

        full_sqtr_size = Calculate_sqrt_floor(work_bits.Length);
        Create_img(work_bits, full_sqtr_size);
        title_text.text = Text_Data.Get_raw_text();
        //current_key = Static_Data.Get_key();

        steps = laundry_data.Get_work_bytes();
    }
예제 #2
0
    private void Show_iteration()
    {
        int temp_iteration = current_iteration + 1;

        if (cipher_state == Cipher_State.Encryption)
        {
            title_text.text = Text_Data.Get_encrypted_text() + Text_Data.Get_round_text() + temp_iteration.ToString();
        }
        else
        {
            title_text.text = Text_Data.Get_decrypted_text() + Text_Data.Get_round_text() + temp_iteration.ToString();
        }

        work_bits     = laundry_data.Get_work_bits();
        end_of_blocks = false;
        current_block = 0;
        current_iteration++;

        if (current_iteration >= number_of_iterations)
        {
            end_of_iteration = true;
        }

        Set_current(work_bits, Calculate_sqrt_floor(work_bits.Length));
        Create_img(current_bits, currnet_sqtr_size);
    }
예제 #3
0
    private void Encryption_end()
    {
        title_text.text = Text_Data.Get_encrypted_end_text();

        //work_bits = laundry_data.Get_work_bits();

        BitArray bits = null;

        for (int i = 0; i < encrypted.Length; i++)
        {
            if (i == 0)
            {
                bits = new BitArray(BitConverter.GetBytes(encrypted[i]));
            }
            else
            {
                bits.Append(new BitArray(BitConverter.GetBytes(encrypted[i])));
            }
        }


        Set_current(bits, Calculate_sqrt_floor(bits.Length));
        Create_img(current_bits, currnet_sqtr_size);

        Ready_up_dectyption();
    }
예제 #4
0
    private void Decryption_end()
    {
        title_text.text = Text_Data.Get_decrypted_end_text();

        BitArray bits = null;

        for (int i = 0; i < decrypted.Length; i++)
        {
            if (i == 0)
            {
                bits = new BitArray(BitConverter.GetBytes(decrypted[i]));
            }
            else
            {
                bits.Append(new BitArray(BitConverter.GetBytes(decrypted[i])));
            }
        }

        Set_current(bits, Calculate_sqrt_floor(bits.Length));
        Create_img(current_bits, currnet_sqtr_size);

        left_main.SetActive(false);
        var bytes = Converter_Helper.Binary_to_byte(current_bits);

        if (cipher_type == Cipher_Type.Txt)
        {
            left_txt.SetActive(true);

            var txt = dmessage;
            left_txt_output           = txt;
            left_txt_input_field.text = left_txt_output;
        }
        else
        {
            left_img.SetActive(true);

            var img = Converter_Helper.Bytes_to_img(bytes);
            img.Save(Application.persistentDataPath + "/img.jpeg");
            WWW    www    = new WWW("file:///" + Application.persistentDataPath + "/img.jpeg");
            Sprite sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0));
            left_img_img.sprite = sprite;
        }
    }
예제 #5
0
    //=== CIPHER =====================================================================================================================================================

    private void Show_block()
    {
        int temp_round = current_iteration + 1;
        int temp_block = current_block + 1;

        if (cipher_state == Cipher_State.Encryption)
        {
            title_text.text = Text_Data.Get_encrypted_text() + Text_Data.Get_round_text() + temp_round.ToString() + Text_Data.Get_block_text() + temp_block.ToString();
        }
        else
        {
            title_text.text = Text_Data.Get_decrypted_text() + Text_Data.Get_round_text() + temp_round.ToString() + Text_Data.Get_block_text() + temp_block.ToString();
        }

        BitArray bits_temp = Calculate_block();

        Set_current(bits_temp, Calculate_sqrt_floor(bits_temp.Length));
        Create_img(current_bits, currnet_sqtr_size);
    }