private async void button9_Click(object sender, EventArgs e) { //crypt if (_isProcessRun) { MessageBox.Show("Process is run!"); return; } string plainFilePath = textBox7.Text; //source string cryptedFilePath = textBox6.Text; //dest string password = textBox3.Text; try { if (plainFilePath.Equals("")) { throw new Exception("file path not inputed! Please input path"); } if (cryptedFilePath.Equals("")) { throw new Exception("Encrypted file path not inputed! Please output path"); } if (password.Equals("")) { throw new Exception("Password not inputed! Please input password"); } await Task.Factory.StartNew(() => { try { Stopwatch sw = new Stopwatch(); sw.Start(); _isProcessRun = true; MyRc5 crypter = MyRc5.GetRc5(64, password, 16, 16); crypter.OnDecryptedPasswordFailed += CrypterOnOnDecryptedPasswordFailed; crypter.OnProgressChanged += CrypterOnOnProgressChanged; crypter.OnProcessEnded += CrypterOnOnProcessEnded; crypter.Encrypt(plainFilePath, cryptedFilePath); _isProcessRun = false; sw.Stop(); label1.Invoke((MethodInvoker) delegate { label1.Text = String.Format("rc5 time = {0}ms", sw.ElapsedMilliseconds); }); MessageBox.Show("Encryption complete"); } catch (Exception) { MessageBox.Show("Some error with encryption"); } }); } catch (Exception ex) { _isProcessRun = false; MessageBox.Show(ex.Message); } }
private async void button1_Click(object sender, EventArgs e) {//crypt if (_mIsProcessRun) { MessageBox.Show("Process is run!"); return; } string plainFilePath = textBox1.Text; //source string cryptedFilePath = textBox2.Text; //dest string password = textBox3.Text; try { if (plainFilePath.Equals("")) { throw new Exception("file path not inputed! Please input path"); } if (cryptedFilePath.Equals("")) { throw new Exception("Encrypted file path not inputed! Please output path"); } if (password.Equals("")) { throw new Exception("Password not inputed! Please input password"); } InputAlgoData(); await Task.Factory.StartNew(() => { try { _mIsProcessRun = true; MyRc5 crypter = MyRc5.GetRc5(_mWordLength, password, _keyLength, _numberOfRounds); crypter.OnDecryptedPasswordFailed += CrypterOnOnDecryptedPasswordFailed; crypter.OnProgressChanged += CrypterOnOnProgressChanged; crypter.OnProcessEnded += CrypterOnOnProcessEnded; crypter.Encrypt(plainFilePath, cryptedFilePath); _mIsProcessRun = false; MessageBox.Show("Encryption complete"); } catch (Exception) { MessageBox.Show("Some error with encryption"); } }); } catch (Exception ex) { _mIsProcessRun = false; MessageBox.Show(ex.Message); } }