What is the RC4 encryption algorithm?

Updated: 2026 December 02 Time to read: ~

TL;DR

Rivest Cipher 4 (RC4) is a widely used stream cipher that encrypts data one byte at a time using a secret key, a key-scheduling algorithm (KSA), and a pseudo-random generation algorithm (PRGA). While it is fast and easy to implement, RC4 carries significant security vulnerabilities, including susceptibility to hacking when keys are reused, and has been explicitly banned by the Internet Engineering Task Force (IETF) in certain contexts. Newer variants like RC4A, Variably Modified Permutation Composition (VMPC), and Spritz offer improvements but do not fully eliminate the risks.

What is RC4 encryption?

RC4 is a form of stream cipher. It encrypts messages one byte at a time via an algorithm.

Plenty of stream ciphers exist, but RC4 is among the most popular. It's simple to apply, and it works quickly, even on very large pieces of data. If you've ever used an application like TLS (Transport Layer Security) or SSL (secure socket layer), you've probably encountered RC4 encryption. 

But you may not know how it works.

We'll take a high-level approach and explain what the Rivest Cipher is in terms anyone can understand. We'll also explain why it's helpful, and we'll point out a few known limitations.

What is a Rivest Cipher? 

In 1987, Ron Rivest developed the RC4 encryption method. He intended to keep the rules of the cipher secret, and if his plan had worked, he would have created one of the safest tools anyone could use to protect information. Unfortunately, his plans didn't succeed. 

In 1994, an anonymous person posted an intricate description of the cipher's rules in a public space. Now that RC4's rules are out in the open, we know much more about how it works. Unfortunately, that means hackers know a lot more about how to break it too. 

RC4 relies on:

  • Key inputs. This tool generates an eight-bit number (cipher) that's impossible to guess. 
  • Keystreams. The cipher scrambles plain text. 
  • Product. An exclusive OR (X-OR) operation combines the keystream with the cipher. 

What improvements have been made to RC4?

Developers continue to build on and improve RC4 encryption. They hope to minimize hacking risks, although experts say hackers can still get through. New versions include:

  • RC4A — a more complex variant of RC4 designed to be harder to break.
  • VMPC — another improved version that takes longer to crack than the original RC4.
  • SPRITZ — a redesigned successor to RC4 offering greater complexity and resistance to attacks.

All are more complex and take longer to break, but the hacking risks persist. 

Programmers keep working on tools like this due to ongoing hacking risks. Encryption protects very delicate information, including company trade secrets. People must share that data so others can work with it. But without encryption, anyone could see the data as it passes from one person to another. 

Poor encryption tools create vulnerabilities hackers can exploit. The stronger the system, the more completely it can protect you.

How does RC4 work? 

RC4 encryption isn't omnipresent. In fact, the IETF has explicitly banned RC4's use in some spaces. But knowing how the tool works could help you improve upon it as you look for ways to protect your data. 

To explain things simply, RC4 relies on this step-by-step model:

  • Initiate: You input a secret key and the text you'd like to protect. 
  • Encrypt: The cipher scrambles your text via encryption. The work happens byte by byte rather than in chunks. 
  • Send: Your scrambled text heads to the recipient. That person should have a copy of the secret key you used to protect the data. 
  • Decryption: The recipient walks back through these steps to uncover your original text. 

For the math-minded among us, let's dig a little deeper. RC4 relies on two mathematical concepts:

  • KSA: A key-scheduling algorithm initializes the process in an array typically referred to as "S." That "S" is processed 256 times, and bytes from the key are mixed in too. 
  • PRGA: Data is fed in byte by byte, and a mathematical model modifies it. The model looks up values, add them to 256, and uses the sum as the byte within the keystream. It swaps each element with another at least once every 256 rounds. 

RC4 relies on random number generators. But unlike other stream ciphers, RC4 doesn't need linear-feedback shift registers. 

How fast and complex is RC4 encryption?

RC4's encryption tools are sophisticated. They typically contain 256 bytes, and the text passes through mathematical rules multiple times before it's considered complete. If you intercept data encrypted with RC4, you'll see only a series of zeroes and ones. But if you have the proper key, you can transform that data into legible information.

Despite its complexity, RC4 is remarkably fast. In fact, it's one of the fastest tools on the market. For people who don't want to spend long minutes on both encryption and decryption, that speed is ideal.

What are the pros and cons of RC4?

Should you use this form of encryption, or should you keep digging until you find a tool that's perfect in every way? Understanding the risks and benefits can help you make a smart choice for yourself and your business. 

ProsCons
Fast encryption and decryption speedVulnerable to hacking, especially with repeated key use
Easy to implement with just a few lines of codeNot suitable for small data payloads
No lag or drag for end usersBanned by the IETF in certain use cases

Speed and ease of use are among RC4's major benefits. With just a few lines of code, you can implement protections with RC4 encryption, and you won't cause any kind of lag or drag for your users. 

But RC4 can be hacked, especially if you use the same key repeatedly. If a hacker breaks the code once, and you use the same key, you've extended an open invitation to decode everything you send. You must proceed with care. 

RC4 also isn't ideal if you have tiny bits of data to send across. The tool is meant for use on very large pieces of information, and it can break down when applied to something small.

Move past encryption

Scrambling data before you send it should be part of every company's security plan. But you'll also need to protect your servers, and you'll need tools to help you spot and stop malignant software. We can help.

At Okta, we're industry leaders in security. Learn more.

Frequently asked questions

What makes Rivest Cipher 4 (RC4) different from other stream ciphers?

Unlike many other stream ciphers, RC4 does not rely on linear-feedback shift registers. It uses a key-scheduling algorithm (KSA) and a pseudo-random generation algorithm (PRGA) to encrypt data one byte at a time, making it notably fast and simple to implement with minimal code.

Why has Rivest Cipher 4 (RC4) been banned in some applications?

The Internet Engineering Task Force (IETF) has explicitly prohibited RC4's use in certain contexts due to its known security vulnerabilities. Because RC4's internal rules became public in 1994, hackers gained detailed knowledge of how to exploit it, particularly when the same encryption key is reused.

What happens if the same Rivest Cipher 4 (RC4) key is used more than once?

Reusing the same key is one of RC4's most significant weaknesses. If a hacker successfully breaks the encryption once, reusing that key effectively gives them an open invitation to decode all subsequent messages encrypted with it.

What are the newer versions of Rivest Cipher 4 (RC4) and are they safer?

Developers have created improved variants including RC4A, VMPC, and SPRITZ. These versions are more complex and take longer to break, but security experts note that hacking risks still persist even with these updated implementations.

Is Rivest Cipher 4 (RC4) suitable for encrypting small amounts of data?

No. RC4 is designed for use on large pieces of information and can break down when applied to small data payloads. For small data, other encryption methods may be more appropriate.

What does Rivest Cipher 4 (RC4)-encrypted data look like if intercepted?

If someone intercepts data encrypted with RC4, they will see only a series of zeroes and ones. The data only becomes legible when the recipient applies the correct secret key to reverse the encryption process.

References

Ethical Hacking: Breaking Cryptography (For Hackers). (September 2019). Infosec. 

Prohibiting RC4 Cipher Suites. (February 2015). Internet Engineering Task Force.

The RC4 Stream Encryption Algorithm. (2005). William Stallings. 

Stream Ciphers and Message Integrity. (June 2017). Alexei Kojenov.

Continue your Identity journey