Beispiel #1
0
        private void uiDecryptButton_Click(object sender, EventArgs e)
        {
            try
            {
                var watch = new Stopwatch();
                watch.Start();
                using (FileStream fstream = new FileStream(inputFilePath, FileMode.OpenOrCreate))
                {
                    _buffer = new byte[fstream.Length];

                    fstream.Read(_buffer, 0, _buffer.Length);

                    var rc5 = new RC5.RC5(uiKeyField.Text, _buffer);

                    _buffer = rc5.Decrypte_RC5_CBC_Pad();
                }

                using (FileStream fstream = new FileStream(outputFilePath, FileMode.OpenOrCreate))
                {
                    fstream.Write(_buffer, 0, _buffer.Length);
                }
                watch.Stop();
                textBox5.Text = "" + watch.ElapsedMilliseconds;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
            }
        }
Beispiel #2
0
        //asdfa
        private void uiEncryptButton_Click(object sender, EventArgs e)
        {
            try
            {
                var watch = new Stopwatch();
                watch.Start();
                var InputStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read);
                using (FileStream fstream = new FileStream(outputFilePath, FileMode.OpenOrCreate)) //зчитуємо вміст файлу і записуємо в fstream
                {
                    _buffer = new byte[InputStream.Length];                                        //ініціалізуємо масив байтів довжини яка зчиталась

                    InputStream.Read(_buffer, 0, _buffer.Length);                                  //записуємо весь вміст байтів в буфер

                    var rc5 = new RC5.RC5(uiKeyField.Text, _buffer);

                    _buffer = rc5.Encrypte_RC5_CBC_Pad();//зашифрований вміст файлу

                    fstream.Position = 0;

                    fstream.Write(_buffer, 0, _buffer.Length);//записуємо вміст файлу
                }
                watch.Stop();
                textBox5.Text = "" + watch.ElapsedMilliseconds;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
            }
        }