コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            long  initial_seed = 0;
            short size_seed    = 0;
            bool  good         = true;

            if (Binary.Checked)
            {
                if (txtGaussSigma.Text.Length > 64)
                {
                    MessageBox.Show("Binary password length should not exceed 64 letters");
                    good = false;
                }
                else
                {
                    initial_seed = Convert.ToInt64(txtGaussSigma.Text, 2);
                    size_seed    = (short)txtGaussSigma.Text.Length;
                }
            }
            else
            {
                if (txtGaussSigma.Text.Length > 8)
                {
                    good = false;
                    MessageBox.Show("Character password length should not exceed 8 letters");
                }
                else
                {
                    initial_seed = size_seed = 0;
                    set_password(txtGaussSigma.Text.ToString(), ref initial_seed, ref size_seed);
                }
            }
            if (!good)
            {
                return;
            }
            short     tap_pos = (short)nudMaskSize.Value;
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            long tmp = initial_seed;

            RGBPixel[,] arr = ImageOperations.Encrypt_No_cycles(ImageMatrix, size_seed, tap_pos, initial_seed);
            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds + " ms to encrypt");
            sw.Reset();
            sw.Start();
            HuffmanTree tree = new HuffmanTree(arr, initial_seed, tap_pos, size_seed);

            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds + " ms to compress");
            ImageOperations.DisplayImage(arr, pictureBox2);
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            RGBPixel[,] tmp;
            HuffmanTree obj  = new HuffmanTree();
            long        seed = 0;
            short       tap  = 0;
            short       size = 0;
            Stopwatch   sw   = new Stopwatch();

            sw.Start();
            tmp = obj.Decompress("logs.dat", ref seed, ref tap, ref size);
            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds + " ms to decompress");
            sw.Reset();
            sw.Start();
            tmp = ImageOperations.Encrypt_No_cycles(tmp, size, tap, seed);
            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds + " ms to decrypt");
            ImageOperations.DisplayImage(tmp, pictureBox2);
        }