Is there a way to improve the speed for a XOR-Encryption Algorithm somehow by using some tricks (unsafe code or so)?
My current algorithm I am using is the following:
public byte[] XOR(byte[] strng, byte[] key)
{
int string_len = strng.Length;
int key_length = key.Length;
int i, position;
for (i = 0; i < string_len; i++)
{
position = i % key_length;
strng[i] = Convert.ToByte(strng[i] ^ key[position]);
}
return strng;
}
Can this function be improved and speed up somehow?