⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program.cs

📁 简单文件加密 文件通过字节异或 达到简单的文件加密
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace 文件的异或
{
    class Program
    {
        private const string Fn1 = "MyFile1.txt";
        private const string Fn2 = "MyFile2.txt";
        private const string Fn3 = "MyFile3.txt";
        
        static void Main(string[] args)
        {
            Console.WriteLine("异或的内容分别在文件MyFile1.text和MyFile2.text中。");
            

            FileStream sw1 = new FileStream(Fn1,FileMode.Open,FileAccess.Read,FileShare.Read);
            FileStream sw2 = new FileStream(Fn2,FileMode.Open,FileAccess.Read,FileShare.Read);
           
            
               if(sw1.Length != sw2.Length)
            {
                Console.WriteLine("文件长度不一样!");
                return;
            }

            Stream sr = new FileStream(Fn3, FileMode.Create, FileAccess.ReadWrite);

            int numBytes = (int)sw2.Length;
            for (int i = 0; i < numBytes; i++)
            {
                sr.WriteByte((Byte)(sw1.ReadByte() ^ sw2.ReadByte()));
            }
            sw1.Close();
            sw2.Close();
            sr.Close();


        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -