I made a small program which will encrypt my files using xor encryption method.
It work but to encrypt 11MB file it take like 20 mins.
any suggestions on how to make it faster would be nice.
This is the function that encrypt (this is a thread):
publicvoid encrypt()
{
int let = 0;
long length;
this.go = true;
FileStream fopen = new FileStream(this.open, FileMode.Open);
FileStream fsave = new FileStream(this.save, FileMode.OpenOrCreate);
length = fopen.Length;
progressBar.Invoke((MethodInvoker)delegate
{
progressBar.Maximum = Convert.ToInt32(length);
});
while (length > fopen.Position && this.go == true)
{
if (this.password.Length != let)
{
fsave.WriteByte(Convert.ToByte(fopen.ReadByte() ^ this.password[let]));
progressBar.Invoke((MethodInvoker)delegate
{
progressBar.Value++;
});
let++;
}
else
{
let = 0;
}
}
fopen.Dispose();
fopen.Close();
fsave.Dispose();
fsave.Close();
if (this.go == false)
{
File.Delete(this.save);
}
}
and this function also decrypts the file you encrypt.