So with the help of you guys I finished creating my very simple image encrypter. It's enough to keep any non-tech person out, right? :P
Now to the next step. Someone suggested I use XOR. I read about XOR and it's basically a logical table that determines what the answer is between two bits, right?
Only when one is true, the statement is true.
0 0 = false 1 0 = true 0 1 = true 1 1 = false
Is this correct? So, how would I go about XOR encrypting an image?
Here's my previous way using a Caeser cipher.
private void EncryptFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
dialog.InitialDirectory = @"C:\";
dialog.Title = "Please select an image file to encrypt.";
byte[] ImageBytes;
if (dialog.ShowDialog() == DialogResult.OK)
{
ImageBytes = File.ReadAllBytes(dialog.FileName);
for (int i = 0; i < ImageBytes.Length; i++)
{
ImageBytes[i] = (byte)(ImageBytes[i] + 5);
}
File.WriteAllBytes(dialog.FileName, ImageBytes);
}
}
private void DecryptFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
dialog.InitialDirectory = @"C:\";
dialog.Title = "Please select an image file to decrypt.";
byte[] ImageBytes;
if (dialog.ShowDialog() == DialogResult.OK)
{
ImageBytes = File.ReadAllBytes(dialog.FileName);
for (int i = 0; i < ImageBytes.Length; i++)
{
ImageBytes[i] = (byte)(ImageBytes[i] - 5);
}
File.WriteAllBytes(dialog.FileName, ImageBytes);
}
}