RC4 is a symmetric key encryption algorithm that uses a variable key size stream cipher. It operates by initializing a state vector S with values from 0 to 255, and then performing an initial permutation on S based on the secret key. A keystream is then generated by iterating through S, swapping values, and using the result to XOR with plaintext to produce ciphertext. The example demonstrates encrypting a 3-bit plaintext stream using an 8x3-bit simplified RC4 with a 4x3-bit key.