Key Length: 6 characters
Cleaned: HELLO
What is RC4?
RC4 (Rivest Cipher 4) is a stream cipher that generates a pseudorandom keystream from a secret key. The keystream is XORed with plaintext to produce ciphertext. It's simple, fast, but now considered weak for many applications.
How It Works
Pseudorandom Number Generator (PRNG)
A PRNG generates a sequence of numbers that appear random but are deterministic - given the same seed (key), it always produces the same sequence. RC4's PRGA is the PRNG that generates keystream bytes using the initialized S-box and two counters (i, j).
Plaintext
HELLO
Ciphertext
ERGZM
Stream Cipher vs Block Cipher
RC4 is a stream cipher - it encrypts one byte at a time with a unique keystream byte. Block ciphers encrypt fixed-size blocks. Stream ciphers are faster but have different security properties.
Pseudorandom Properties
The keystream appears random but is deterministic - the same key always produces the same keystream. This determinism is essential for decryption (C XOR Keystream = P).
Why RC4 is Weak
RC4 has biases in its keystream output, especially in early bytes. The first 256 bytes should be discarded. The entire first 256 bytes should be skipped in modern implementations. Modern alternatives: AES, ChaCha20.
Applications
Historically used in SSL/TLS, WEP, WPA. Now deprecated in most standards due to security weaknesses. Useful for understanding stream ciphers and PRNG concepts in cryptography education.
Note: This implementation is for educational purposes only. Never use RC4 for real-world security. The demonstration omits the recommended practice of discarding the first 256 bytes of keystream output.