예제 #1
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            Compressor = new HaffmanCompressor();

            if (tbDecodeFile.Text == "")
            {
                string str  = tbEncodeFile.Text;
                int    ind1 = str.LastIndexOf('.');
                int    ind2 = str.LastIndexOf('.', ind1 - 1);
                tbDecodeFile.Text = tbEncodeFile.Text + str.Substring(ind2, ind1 - ind2);
            }

            PermCounter Counter = new PermCounter();

            Counter.Start();
            bool Success = Compressor.Decompress(tbEncodeFile.Text, tbDecodeFile.Text);

            tbDecodeTime.Text = Counter.Finish().ToString("F03");
            //MessageBox.Show("File successfully has been decompressed");

            if (Success)
            {
                MessageBox.Show("Original and decoded files identical!!! Decoding success");
            }
            else
            {
                MessageBox.Show("Original and decoded files are not identical. Decoding fail");
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            SimpleNumber SN = new SimpleNumber();
            PermCounter  PC = new PermCounter();

            PC.Start();
            SN.WriteSimpleNumbers("../../Data/Simple Numbers.dat", uint.MaxValue);
            MessageBox.Show("Complete at " + PC.Finish().ToString());
        }
예제 #3
0
        private void btnCrypt_Click(object sender, EventArgs e)
        {
            if (tbEncodeFile.Text == "")
            {
                tbEncodeFile.Text = tbSorceFile.Text + ".encode";
            }

            PermCounter Counter = new PermCounter();

            Counter.Start();
            RSACrypt.Encode(tbSorceFile.Text, tbEncodeFile.Text, new RSAKey(Convert.ToInt64(tbKey1.Text), Convert.ToInt64(tbModule.Text)));
            tbEncodeTime.Text = Counter.Finish().ToString("F03");

            MessageBox.Show("File successfully encoded");
        }
예제 #4
0
        private void btnCrypt_Click(object sender, EventArgs e)
        {
            if (tbEncodeFile.Text == "")
            {
                tbEncodeFile.Text = tbSorceFile.Text + ".encode";
            }

            PermCounter Counter = new PermCounter();

            Counter.Start();
            DESCrypt.Encode(tbSorceFile.Text, tbEncodeFile.Text, UInt64.Parse(tbKey.Text));
            tbEncodeTime.Text = Counter.Finish().ToString("F03");

            MessageBox.Show("File successfully encoded");
        }
예제 #5
0
        private void btnCrypt_Click(object sender, EventArgs e)
        {
            Compressor = new HaffmanCompressor();

            if (tbEncodeFile.Text == "")
            {
                tbEncodeFile.Text = tbSorceFile.Text + ".hcs";
            }

            PermCounter Counter = new PermCounter();

            Counter.Start();
            float Ratio = Compressor.Compress(tbSorceFile.Text, tbEncodeFile.Text);

            tbEncodeTime.Text = Counter.Finish().ToString("F03");
            MessageBox.Show("File successfully has been compressed");

            tbRatio.Text = Ratio.ToString("F04");
        }
예제 #6
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            if (tbDecodeFile.Text == "")
            {
                string str  = tbEncodeFile.Text;
                int    ind1 = str.LastIndexOf('.');
                int    ind2 = str.LastIndexOf('.', ind1 - 1);
                tbDecodeFile.Text = tbEncodeFile.Text + str.Substring(ind2, ind1 - ind2);
            }
            PermCounter Counter = new PermCounter();

            Counter.Start();
            RSACrypt.Decode(tbEncodeFile.Text, tbDecodeFile.Text, new RSAKey(Convert.ToInt64(tbKey2.Text), Convert.ToInt64(tbModule.Text)));
            tbDecodeTime.Text = Counter.Finish().ToString("F03");

            StreamReader Reader = new StreamReader(tbSorceFile.Text);

            byte[] OrigArray = new byte[Reader.BaseStream.Length];
            Reader.BaseStream.Read(OrigArray, 0, (int)Reader.BaseStream.Length);
            Reader.Close();
            Reader = new StreamReader(tbDecodeFile.Text);
            byte[] DecodeArray = new byte[Reader.BaseStream.Length];
            Reader.BaseStream.Read(DecodeArray, 0, (int)Reader.BaseStream.Length);
            Reader.Close();

            OrigArray   = SHA1.Create().ComputeHash(OrigArray);
            DecodeArray = SHA1.Create().ComputeHash(DecodeArray);
            if (OrigArray.SequenceEqual(DecodeArray))
            {
                MessageBox.Show("Original and decoded files identical!!! Decoding success");
            }
            else
            {
                MessageBox.Show("Original and decoded files are not identical. Decoding fail");
            }
        }