zoukankan      html  css  js  c++  java
  • 利用异或进行的简单文件加密算法

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;//

    namespace DESFileSmart
    {
        public class DESFileSmartClass
        {
            /// <summary>
            /// 加/解密文件算法
            /// </summary>
            /// <param name="inFile"></param>
            /// <param name="outFile"></param>
            /// <param name="password"></param>
            public static void DESFile(string inFile, string outFile, int password)
            {
                // 创建打开文件流
                using (FileStream fin = File.OpenRead(inFile), fout = File.OpenWrite(outFile))
                {
                    byte[] inData = new byte[fin.Length];
                    byte[] outData = new byte[fin.Length];
                    fin.Read(inData, 0, inData.Length);
                    for (int i = 0; i < inData.Length; i++)
                    {
                        int temp = inData[i]^password;
                        outData[i] = (byte)temp;
                    }
                    fout.Write(outData, 0, outData.Length);
                }
            }
        }
    }

  • 相关阅读:
    Chapter 17_1 弱引用table
    Chapter 16_5 单一方法
    Chapter 16_4 私密性
    Chapter 16_3 多重继承
    Chapter 16_2 继承
    Chapter 16_1 Class
    Chapter 16_0 面向对象编程
    小米2s刷机
    Chapter 15_4 子模块和包
    ASP.NET Core MVC 泛型接口的声明调用与注入服务
  • 原文地址:https://www.cnblogs.com/mane/p/2036432.html
Copyright © 2011-2022 走看看