HC-128 explained in plain terms means understanding a stream cipher built for speed, a design that encrypts data quickly on ordinary processors by keeping its state in two large tables and updating them as it goes. The central question is how a cipher can be both fast and secure when speed usually means cutting corners, and the answer is that HC-128 spends its budget on memory rather than on complicated mathematics.
HC-128 is a stream cipher designed by Hongjun Wu and published in 2004, submitted to the eSTREAM project and chosen for its software portfolio in 2008. It takes a 128-bit key and a 128-bit initialisation vector, keeps its state in two tables of 512 words each, and produces a 32-bit keystream word at every step, which makes it fast on the processors it was built for.
This article explains what HC-128 is, how it works, and where it already runs.
Key takeaways
- HC-128 is a stream cipher designed by Hongjun Wu in 2004.
- It uses a 128-bit key and a 128-bit initialisation vector.
- It keeps its state in two tables of 512 words each.
- It was selected for the eSTREAM software portfolio in 2008.
- It produces a full 32-bit keystream word at every step.
What HC-128 is
HC-128 is a cipher that encrypts data as a continuous stream rather than in fixed-size blocks, generating a long sequence of pseudo-random words from a short key and combining that sequence with the message. The keystream must never be reused with the same key and initialisation vector, because reusing it would let an attacker recover the plaintext by combining two ciphertexts, which is the one rule every stream cipher shares.
Its signature feature is the pair of tables. Each table holds 512 32-bit words, and the cipher updates one table entry at every step while generating a keystream word from the other table, which means the state is large, four kilobytes in total, and the cipher’s security rests on the way those tables evolve rather than on any single clever operation.
The design was a reaction to the needs of software encryption. Stream ciphers built for hardware produce one bit at a time, which is wasteful on a processor that handles 32 bits at once, so Wu designed HC-128 to produce a whole word per step, using table lookups and rotations that processors do quickly, and the result was one of the fastest ciphers in the eSTREAM contest.
It became one of the best-known results of eSTREAM’s software portfolio, the half of the contest that searched for ciphers to run on ordinary computers rather than on tiny chips. HC-128 was praised for its speed and its clean design, and its selection gave it the scrutiny that a cipher needs before anyone trusts it with real data.
Its most famous property is the size of its state. Four kilobytes of tables is large for a stream cipher, and it is a deliberate trade, because a large state makes the cipher harder to attack with the techniques that work against small designs, and on a modern computer four kilobytes of memory is nothing at all.
Our guide to stream ciphers explains the family HC-128 belongs to, and our guide to key derivation explains how keys like the one HC-128 uses are made safely.
How HC-128 works
Everything starts with the key and the initialisation vector, which are expanded into the two tables through 1,024 steps of a setup process. The setup fills both tables from the key and the initialisation vector, mixing them thoroughly before any keystream is produced, which is the cipher’s way of making sure the keystream depends on every bit of the key.
Each step of the cipher updates one entry in one table and generates one keystream word from the other table. The update takes three neighbouring words, combines them with rotations and additions, and writes the result back, which means the table changes constantly as the cipher runs, and a table entry is never used twice in the same state.
The keystream word is built from three table entries combined with rotations and XORs, plus a nonlinear function that takes three words from the table and mixes them through additions and XORs. The function uses different operations depending on the step, which keeps the keystream from settling into a pattern that an attacker could exploit.
The two tables take turns. At even steps the cipher updates the first table and reads from the second, and at odd steps it does the opposite, which means each table gets 512 steps of rest between updates, and that rest is part of the design, because it lets the changes propagate before a table is read again.
The security of the design rests on the size of the state and the way the tables evolve. With 1,024 words of state, an attacker who wants to recover the key must guess or reconstruct far more information than with a small cipher, and the best published attacks need unrealistic amounts of data, which is why HC-128 has survived nearly twenty years of analysis.
Decryption is identical to encryption, because XORing twice with the same keystream returns the original bits. That symmetry is typical of stream ciphers, and it means HC-128 needs no separate decryption routine, which keeps the implementation simple and fast.

Comparing HC-128 with other stream ciphers
HC-128 is one of several stream ciphers, and each was built with a different emphasis. Salsa20 aims for speed in software with a large state and a simple round function, Trivium aims for tiny hardware with three small registers, and the RC4 cipher that once ruled the web was fast but turned out to be fragile, while HC-128 trades memory for speed, and each approach trades something for something else.
The table below sets out the main contrasts between the leading approaches.
| Aspect | HC-128 | Salsa20 | Trivium |
|---|---|---|---|
| Designed for | Fast software | Fast software | Tiny hardware |
| Key size | 128 bits | 256 bits | 80 bits |
| Internal state | 4 kilobytes | 512 bits | 288 bits |
| Output per step | 32-bit word | 512-bit block | 1 bit |
| Best for | Software encryption | Software encryption | Tags and sensors |
The practical result is that HC-128 is the right choice for fast software encryption, Salsa20 suits the same job with a different design, and Trivium fits tiny hardware instead.
Where HC-128 is used
Cryptographic libraries include it for completeness. Libraries such as Botan and Bouncy Castle implement HC-128, because developers who need an eSTREAM software cipher expect to find it there, and because a library without it is incomplete for anyone working with standardised stream ciphers.
Software encryption tools use it where speed matters. Applications that encrypt large amounts of data on ordinary processors benefit from a cipher that produces a full word per step, and HC-128’s design makes it a natural choice for software that cannot afford the overhead of a slower cipher.
Research uses it as a benchmark for new designs. When someone proposes a new software stream cipher, HC-128 is one of the first comparisons they make, because its speed and its security are both well understood, and beating it on either measure without losing the other is the test every new design must pass.
Embedded software uses it where memory is available. Devices with enough memory for the four-kilobyte state can run HC-128 in software, which suits routers, set-top boxes, and other equipment that has a real processor and needs encryption that keeps up with its network speed.
Teaching uses it to show how table-based ciphers work. HC-128’s two-table design is easy to explain and easy to implement, which makes it a favourite example in cryptography courses that cover software stream ciphers and the trade-offs between state size and speed.
Strengths and limits
The greatest strength of HC-128 is its speed in software. Producing a full 32-bit word at every step, with operations that processors handle quickly, makes it one of the fastest stream ciphers of its generation, and that speed is real, measured in published benchmarks and confirmed by independent implementations.
It is also a strength that the design has survived so much scrutiny. Nearly twenty years of published attacks have found only theoretical weaknesses that need unrealistic amounts of data, and a cipher that has been attacked by the whole world and still stands is a cipher worth trusting.
The limits are real, though, and the biggest is the state size. Four kilobytes of tables is nothing on a computer but far too much for the tiny chips that Trivium and Grain were built for, which means HC-128 cannot go where the smallest hardware lives, and that is a deliberate trade rather than a flaw.
HC-128 checklist
- Never reuse a key and initialisation vector pair for two messages.
- Always run the full setup process before using the keystream.
- Use HC-128 in software where speed matters, not on tiny hardware.
- Generate the initialisation vector randomly for every message.
- Remember HC-128 encrypts but does not authenticate on its own.
- Add a message authentication code if tampering is a concern.
- Test the implementation against published test vectors first.
- Keep the key secret and as random as the 128 bits allow.
- Consider a modern authenticated cipher if you need more than encryption.
Frequently asked questions
What is HC-128 in simple terms?
It is a stream cipher that makes a long pseudo-random keystream from a short key, keeping its state in two large tables and producing a full 32-bit word at every step.
Why does HC-128 need two tables?
Two tables let the cipher update one while reading from the other, which keeps the state changing constantly and makes the keystream harder to predict.
How is HC-128 different from Salsa20?
Both are fast software stream ciphers, but HC-128 keeps its state in two tables that evolve step by step, while Salsa20 uses a fixed-size state transformed by rounds.
Is HC-128 still secure?
Yes, no practical attack has been published, and the best known attacks are theoretical ones that need far more data than any real system would ever produce.
Can HC-128 run on tiny hardware?
It can, but its four kilobytes of tables need more memory than tiny chips have, so hardware that small usually chooses Trivium or Grain instead.
When should I use HC-128?
When you need fast encryption in software, your device has memory to spare, and you want a cipher with a long record of public analysis.
The bottom line
HC-128 explained in one line is this: a stream cipher that proves speed and security can go together, by spending memory on two large tables and letting them do the work.
It is the software half of the eSTREAM story, and the reason it still matters is that fast encryption in software is still a job worth doing well, and HC-128 still does it.
This article is general information about how HC-128 works, not advice about choosing encryption for a particular device or system.







