private void btnEncrypt_Click(object sender, EventArgs e) { if (cbHMACMode.Checked) { tbToText.Text = HMACMD5Encryption.Encrypt(tbFromText.Text, tbHMAPassword.Text); } else { tbToText.Text = MD5Encryption.Encrypt(tbFromText.Text); } }
private void btnCheckResult_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } FileInfo file = new FileInfo(tbPath.Text); if (cbHMACMode.Checked) { Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACMD5Encryption.Encrypt(file, tbHMAPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } else { Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => MD5Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } }