RC4 128 bit encryption in C#

According to http://en.wikipedia.org/wiki/Rc4 RC4 algorithm can have keylength which can be in the range 1 ≤ keylength ≤ 256
Here's an example which you can determine the key size: http://tofuculture.com/Blog/post/RC4-Encryption-in-C.aspx
Download the source and view RC4.cs.

UPDATE: The link is dead. here's the Archive.org's snapshot.


Key setup is the first and most difficult phase of this algorithm. During a N-bit key setup (N being your key length), the encryption key is used to generate an encrypting variable using two arrays, state and key, and N-number of mixing operations. These mixing operations consist of swapping bytes, modulo operations, and other formulae.

In the attached project you can see how I do it in the EncryptionKey set property of RC4Engine class.

this is an interesting article for this subject - http://www.codeproject.com/Articles/5068/RC4-Encryption-Algorithm-C-Version