private void btnFileSave2_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } if (tbPassword.Text.Length != 8) { WarningNotice.KeyLength(8); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } if (DialogResult.OK == sfdFile.ShowDialog()) { FileInfo file = new FileInfo(tbPath.Text); FileInfo result = new FileInfo(sfdFile.FileName); Task.Factory.StartNew(() => { try { ControlEnable(this.Controls, false); fileSize = file.Length; RC2Encryption.Decrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); } catch (Exception) { WarningNotice.WrongKey(); } finally { ControlEnable(this.Controls, true); } }); } sfdFile.FileName = ""; }
private void btnDecrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 8) { WarningNotice.KeyLength(8); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } try { tbToText.Text = RC2Encryption.Decrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); } catch (Exception) { WarningNotice.WrongKey(); } }