I am using the following implementation of the RC4 encryption algorithm in C#/// <summary>/// RC4 encryption algorithm/// </summary>/// <param name=bytes>Input bytes</param>/// <param name=key>Key bytes</param>/// <returns>encrypted bytes</returns>public static byte[] Encrypt(byte[] bytes, byte[] key){    byte[] z = new byte[bytes.Length];    byte[] s = new byte[256];    byte[] k = new byte[256];    byte temp;    int i, j;    for (i = 0; i < 256; i++)    {        s[i] = (byte)i;        k[i] = key[i % key.GetLength(0)];    }    j = 0;    for (i = 0; i < 256; i++)    {        j = (j + s[i] + k[i]) % 256;        temp = s[i];        s[i] = s[j];        s[j] = temp;    }    i = j = 0;    for (int x = 0; x < z.GetLength(0); x++)    {        i = (i + 1) % 256;        j = (j + s[i]) % 256;        temp = s[i];        s[i] = s[j];        s[j] = temp;        int t = (s[i] + s[j]) % 256;        z[x] = (byte)(bytes[x] ^ s[t]);    }    return z;}Is it possible to optimize my implementation a bit further, eventually using unsafe code, - especially for the variable swapping?I hope for some constructive criticism.
RC4 implementation
c#;performance;algorithm;cryptography