Tool that lets you encrypt&decrypt a file.
Basically major code is below, but feel free to download full source and compile it.
Code:private void button1_Click(object sender, EventArgs e) { OpenFileDialog xOpen = new OpenFileDialog(); SaveFileDialog xSave = new SaveFileDialog(); xOpen.Title = "Select File to Encrypt/Decrypt"; if (xOpen.ShowDialog() == DialogResult.OK) { if (xSave.ShowDialog() == DialogResult.OK) { SaveFile(xSave.FileName, EncryptBytes(OpenFile(xOpen.FileName), 0xDC)); } } } public byte[] EncryptBytes(byte[] input, byte xorKey) { byte[] output = new byte[input.Length]; for (int i = 0; i < input.Length; i++) { output[i] = (byte)(input[i]^xorKey); xorKey ^= (byte)((input.Length - 1) + i); } return output; } public byte[] OpenFile(string filePath) { FileStream openFile = File.OpenRead(filePath); byte[] inputFile = new byte[openFile.Length]; openFile.Read(inputFile, 0, (int)openFile.Length); openFile.Close(); return inputFile; } public void SaveFile(string filePath, byte[] fileContent) { FileStream saveFile = new FileStream(filePath, FileMode.Create, FileAccess.Write); saveFile.Write(fileContent, 0, (int)fileContent.Length); saveFile.Close(); }
P.S. This is my first product after learning about XOR



Reply With Quote![[C#]File Encryptor](http://ragezone.com/hyper728.png)

