コード例 #1
0
 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     if (cbHMACMode.Checked)
     {
         tbToText.Text = HMACRIPEMD160Encryption.Encrypt(tbFromText.Text, tbHMACPassword.Text);
     }
     else
     {
         tbToText.Text = RIPEMD160Encryption.Encrypt(tbFromText.Text);
     }
 }
コード例 #2
0
        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>(() => HMACRIPEMD160Encryption.Encrypt(file, tbHMACPassword.Text)));
                    task.Wait();
                    this.Invoke(new Action(() => tbResult.Text = task.Result));
                    this.Invoke(new Action(() => WarningNotice.Completed()));
                    ControlEnable(this.Controls, true);
                });
            }
            else
            {
                Task.Factory.StartNew(() =>
                {
                    ControlEnable(this.Controls, false);
                    Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => RIPEMD160Encryption.Encrypt(file)));
                    task.Wait();
                    this.Invoke(new Action(() => tbResult.Text = task.Result));
                    this.Invoke(new Action(() => WarningNotice.Completed()));
                    ControlEnable(this.Controls, true);
                });
            }
        }