Can two rc4 encoded messages be XORed and decrypted if encrypted with the same key? If I have the following:

E1 = RC4(M1, K);
E2 = RC4(M2, K);


If two different messages M1 and M2 are encrypted with the same key, K, can the key be recovered by doing:

K = E1 XOR E2


I tried XORing the two streams and could not get the key. Does RC4 not work this way?
No.  The key is not used to encrypt the message.  RC4 is a stream cipher.  The key is utilized to generate a one-time pad to encrypt the message.  This is what you have actually done:

E1 = RC4(M1,K) = M1 XOR PAD(k)
E2 = RC4(M2,K) = M2 XOR PAD(k)

E1 XOR E2 =&gt; M1 XOR M2


Ergo, RC4 keys are safe for single time use.  You need to concatenate a nonce to the key for multiple use.