利用异或进行的简单文件加密算法
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);
}
}
}
}