Home

RC4

RC4, or Rivest Cipher 4, is a symmetric stream cipher designed by Ron Rivest for RSA Data Security in 1987. It generates a stream of pseudorandom bytes that are XORed with plaintext to produce ciphertext. Its simplicity and speed in software contributed to widespread use in many protocols.

RC4 uses a variable-length key from 1 to 256 bytes to initialize a 256-byte state array S,

During PRGA, i and j are updated, S is swapped, and the output byte K is taken

RC4 has known weaknesses: early keystream biases and key-dependent patterns. Reusing the same key across sessions

RC4 was widely deployed in SSL/TLS and wireless security in earlier decades, but analyses uncovered vulnerabilities

RC4 is now considered obsolete for new designs. Its biases and the availability of secure alternatives such

a
permutation
of
0–255.
The
key
scheduling
algorithm
(KSA)
shuffles
S
using
the
key;
the
pseudo-random
generation
algorithm
(PRGA)
then
iterates
with
two
indices,
producing
a
keystream
byte
for
each
input
byte.
as
S[(S[i]
+
S[j])
mod
256].
The
plaintext
byte
P
is
encrypted
as
C
=
P
XOR
K.
or
improper
protocol
usage
can
enable
attacks.
These
weaknesses
have
led
to
practical
compromises
of
confidentiality
in
some
deployments,
prompting
caution
in
modern
use.
and
standards
gradually
deprecated
it.
By
the
mid-2010s,
major
browsers
and
security
guidelines
advised
against
RC4
in
favor
of
stronger
ciphers.
as
AES-GCM
and
ChaCha20-Poly1305
have
led
to
broad
recommendations
to
avoid
RC4.