private void btnEncrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 8) { WarningNotice.KeyLength(8); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } tbToText.Text = RC2Encryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
private void btnFileSave1_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(() => { ControlEnable(this.Controls, false); fileSize = file.Length; RC2Encryption.Encrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } sfdFile.FileName = ""; }