Пример #1
0
 private void button_sign_Click(object sender, EventArgs e)
 {
     try
     {
         string hash_code   = this.combo_box_hash.SelectedValue.ToString();
         string message     = this.rich_txt_plain.Text.ToString().Trim();
         string signed_text = RSA_1.SignData(message, rsa_paras, hash_code);
         this.rich_txt_sign.Text = signed_text;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Thông báo");
     }
 }
Пример #2
0
        private void button_verify_Click(object sender, EventArgs e)
        {
            try
            {
                string hash_code        = this.combo_box_hash.SelectedValue.ToString();
                string original_message = this.rich_txt_plain.Text.ToString().Trim();
                string signed_message   = this.rich_txt_sign.Text.ToString().Trim();
                bool   verify           = RSA_1.VerifyData(original_message, signed_message, rsa_paras, hash_code);

                if (verify)
                {
                    MessageBox.Show("Xác thực thành công", "Thông báo");
                }
                else
                {
                    MessageBox.Show("Xác thực thất bại", "Thông báo");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Thông báo");
            }
        }