Convert the ASCII string “Key” into a three-byte key

key = ToCharacterCode["Key"]

State of the permutation S as i ranges from 0 to 255, in decimal, for the key “Key”

Manipulate[Block[{j=0,S=Range[0,255]},For[i=0,i<Iteration,i++,j=Mod[(j+S[[i+1]]+key[[Mod[i,Length[key]]+1]]),256];
{S[[i+1]],S[[j+1]]}={S[[j+1]],S[[i+1]]};];
Partition[S,8]//TableForm],{Iteration,0,256,1}]

State of the permutation S as i ranges from 0 to 255, in hexadecimal, for the key “Key”

Manipulate[Block[{j=0,S=Range[0,255]},For[i=0,i<Iteration,i++,j=Mod[(j+S[[i+1]]+key[[Mod[i,Length[key]]+1]]),256];
{S[[i+1]],S[[j+1]]}={S[[j+1]],S[[i+1]]};];
Partition[IntegerString[S,16,2],8]//TableForm],{Iteration,0,256,1}]

Value of i, j, the keystream output byte (in decimal), and S (in decimal), for the first 1024 iterations of RC4 under the key “Key”

Manipulate[Block[{S=Block[{j=0,S=Range[0,255]},For[i=0,i<256,i++,j=Mod[(j+S[[i+1]]+key[[Mod[i,Length[key]]+1]]),256];
{S[[i+1]],S[[Mod[j+1,256]]]}={S[[Mod[j+1,256]]],S[[i+1]]};];
S],i=0,j=0},
For[t=0,t<Iteration,t++,
i=Mod[i+1,256];
j=Mod[j+S[[i+1]],256];
{S[[i+1]],S[[j+1]]}={S[[j+1]],S[[i+1]]};
];{{"i","j","keystream","S"},{i,j,If[t>0,S[[Mod[S[[i+1]]+S[[j+1]],256]+1]],"n/a"],Partition[S,8]//TableForm}}//TableForm[Transpose[#],TableDepth->2]&
],{Iteration,0,1024,1}]

Value of i, j, the keystream output byte (in hexadecimal), and S (in hexadecimal), for the first 1024 iterations of RC4 under the key “Key”

Manipulate[Block[{S=Block[{j=0,S=Range[0,255]},For[i=0,i<256,i++,j=Mod[(j+S[[i+1]]+key[[Mod[i,Length[key]]+1]]),256];
{S[[i+1]],S[[Mod[j+1,256]]]}={S[[Mod[j+1,256]]],S[[i+1]]};];
S],i=0,j=0},
For[t=0,t<Iteration,t++,
i=Mod[i+1,256];
j=Mod[j+S[[i+1]],256];
{S[[i+1]],S[[j+1]]}={S[[j+1]],S[[i+1]]};
];{{"i","j","keystream","S"},{i,j,If[t>0,IntegerString[S[[Mod[S[[i+1]]+S[[j+1]],256]+1]],16,2],"n/a"],Partition[IntegerString[S,16,2],8]//TableForm}}//TableForm[Transpose[#],TableDepth->2]&
],{Iteration,0,1024,1}]

Sample plaintext in hex

IntegerString[ToCharacterCode["Plaintext"],16,2]

Above plaintext encrypted to ciphertext, under the ASCII key “Key”

IntegerString[BitXor[Map[FromDigits[#,16]&,{"EB","9F","77","81","B7","34","CA","72","A7"}],ToCharacterCode["Plaintext"]],16,2]