c#,对数字进行异或加密和加一加密

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void label4_Click(object sender, EventArgs e)
        {


        }


        private void button1_Click(object sender, EventArgs e)
        {
            int num, key;
            if (int.TryParse(textBox1.Text, out num) && int.TryParse(textBox2.Text, out key))
            {
                if (checkBox1.Checked)
                {
                    textBox4.Text = (num ^ key).ToString();
                }
                else if (checkBox2.Checked)
                {
                    textBox4.Text = (num+1).ToString();
                }
                  


            }
            else
            {
                MessageBox.Show("请输入数值","输入错误");


            }
        }


        private void button2_Click(object sender, EventArgs e)
        {
            int key, decode;
            if (int.TryParse(textBox5.Text, out decode) && int.TryParse(textBox2.Text, out key))
            {
                if (checkBox1.Checked)
                {
                    textBox3.Text = (decode ^ key).ToString();
                }
                else if (checkBox2.Checked)
                {
                    textBox3.Text = (decode - 1).ToString();
                }
               


            }
            else
            {
                MessageBox.Show("请输入数值","输入错误");


            }
        }

    }

工程下载地址:

https://download.csdn.net/download/meker1/10403475

相关文章: