Winform中使用异或算法对数字进行加密解密

场景

使用异或算法进行数字加密效果

注:

博客主页:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

新建一个Winform程序,设计窗体页面布局如下

然后需要添加的引用如下

修改其代码为

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

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

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text != "")
                {
                    textBox2.Text = (Convert.ToInt32(textBox1.Text) ^ 123).ToString();
                }
            }
            catch { }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox2.Text != "")
                {
                    textBox1.Text = (Convert.ToInt32(textBox2.Text) ^ 123).ToString();
                }
            }
            catch { }
        }
    }
}
原文地址:https://www.cnblogs.com/badaoliumangqizhi/p/12503209.html