· 15 min read

On this page

The Blowfish encryption algorithm stands out as one of the most impactful developments in cryptography. Designed to be fast and unbreakable within practical limits, this symmetric-key cipher provides robust security for a wide range of digital applications. This guide walks through how Blowfish works, its real-world uses, and the intricacies of implementing and analyzing its strengths and vulnerabilities.

Understanding Blowfish: What Is It?

Blowfish is a symmetric block cipher invented by Bruce Schneier in 1993 as a replacement for the aging DES (Data Encryption Standard). As a 64-bit, block-based encryption technique using variable-length keys, Blowfish quickly gained favor for its flexibility, speed, and resilience against brute-force attacks.

The context of 1993 explains a lot about the design. DES was visibly running out of road with its 56-bit key, but the alternatives were mostly patented, export-restricted, or both — IDEA was patented, RC4 was a trade secret, and US export rules made strong cryptography legally awkward to ship. Schneier’s response was to publish a cipher that was fast on the general-purpose 32-bit CPUs of the era, took keys long enough that brute force was permanently off the table, and came with no patent, no license, and no royalties. That combination is why Blowfish spread as quickly as it did: for years it was the strongest cipher a developer could simply drop into a project without a lawyer.

Three decades on, the algorithm itself is still unbroken. Its problem is a structural one — the 64-bit block size it inherited from the DES era — and that limitation, rather than any cryptanalytic weakness, is what determines where Blowfish is and isn’t appropriate today.

Key Features

Four design decisions define the cipher and explain both its early popularity and its current niche:

  • Variable key length — supports keys ranging from 32 to 448 bits, offering high adaptability based on security needs. The wide range was a deliberate accommodation of 1990s export restrictions, which capped key lengths for software shipped outside the US; the low end of that range should never be used today.
  • Fast performance — designed for high speed on 32-bit microprocessors, making it suitable for software applications. Blowfish encrypts using simple table lookups, additions, and XORs, all of which map cleanly onto ordinary CPU instructions with no specialised hardware required.
  • Public domain — Blowfish is unpatented and freely available, enabling widespread adoption without licensing barriers. Schneier explicitly placed it in the public domain, and reference implementations have been freely redistributable from the start.
  • Simplicity and strength — its simple structure facilitates easy implementation, but the complex key expansion and Feistel network ensure strength. The core encryption routine is short enough to read in one sitting, which made independent implementations and review unusually easy.

How Does Blowfish Encryption Work?

At its core, Blowfish processes data blocks of 64 bits through a 16-round Feistel network. Each round uses a key-dependent lookup in S-boxes and permutation boxes (P-boxes) derived from the encryption key.

  • Key expansion — the input key is converted into several subkeys, populating the P-boxes and S-boxes. The process is computation-heavy but guarantees resistance to key-related attacks.
  • F-function — each round employs an F-function (a combination of addition, XOR, and lookup operations) to scramble the message, ensuring diffusion and confusion per Shannon’s principles.
  • Encryption and decryption — both operations use the same algorithm structure but reverse the order of subkeys. Blowfish is fast and secure for encryption, though its key setup can be slow for each new key.

Why key expansion is so expensive

The key expansion step deserves a closer look, because it’s the most unusual thing about the cipher and the reason Blowfish outlived its own block size.

Blowfish’s subkeys aren’t a lightweight derivation from the key — they’re an 18-entry P-array plus four S-boxes of 256 entries each, all of them 32 bits wide. Every one of those entries starts life as a fixed constant taken from the hexadecimal digits of pi, a “nothing-up-my-sleeve” choice that lets anyone verify the initial state contains no hidden structure. The key is then XORed into the P-array, and the algorithm repeatedly encrypts a running block with the tables it has built so far, using each output to overwrite the next pair of entries — until every entry has been replaced. Setting up a single Blowfish key takes 521 runs of the encryption routine.

That’s enormously slow by cipher standards, and it cuts two ways. For bulk encryption under one long-lived key it’s a one-off cost that disappears against the data volume. For anything that rekeys frequently, it’s a genuine tax. But it also makes exhaustive key search dramatically more expensive than the key length alone suggests, because every candidate key an attacker tries costs them a full setup rather than a single trial encryption — a property later exploited deliberately, as the section on password hashing below explains.

Strengths and Advantages

  • A clean cryptanalytic record — no practical attack has ever broken full-round Blowfish, so the idea of “Blowfish cracked” is closer to folklore than fact. Published analysis reaches only reduced-round variants and a narrow class of weak keys, neither of which threatens a correctly used 16-round implementation. Brute force against a long key is not remotely feasible, and the expensive key schedule makes it even less so.
  • Speed once the key is loaded — after setup, Blowfish is genuinely fast in pure software. The round function is nothing but table lookups, 32-bit additions, and XORs, so it performs well on modest hardware and needs no cryptographic accelerator. That made it the pragmatic choice for VPNs, file encryption, and custom protocols throughout the late 1990s and 2000s.
  • Available everywhere, encumbered by nothing — Blowfish has been implemented in essentially every major programming language, and its public-domain status means no license to review, no royalties, and no export paperwork. For embedded devices, legacy products, and anything shipping into uncertain legal territory, that mattered enormously.
  • Small and auditable — the implementation is compact, with a short round function and modest memory needs beyond the key tables. That combination of small code and open specification made it easy for third parties to implement and verify independently, which is a real security property in its own right.

Weaknesses and Limitations

Despite its dependability, Blowfish is not without caveats — and one of them is serious enough to decide the question for most modern systems:

  • Block size limitation — with a 64-bit block size, Blowfish is vulnerable to birthday attacks if large volumes of data are encrypted with the same key. Risks increase after roughly 32GB processed under one key.
  • No hardware acceleration — modern processors include dedicated instructions for AES but nothing equivalent for Blowfish, so on current hardware AES is not just more secure but substantially faster, reversing the performance argument that made Blowfish attractive in the first place.
  • Expensive rekeying — the 521-iteration key setup penalises any protocol that establishes a fresh key per session or per message.
  • Fixed structure — Blowfish doesn’t support modern authenticated encryption schemes without custom modifications, so you’re left composing encryption and authentication yourself instead of using a single vetted authenticated mode.
  • Replacement by modern ciphers — algorithms such as AES now dominate new deployments, primarily due to larger block sizes (128 bits) and standards approval that Blowfish never sought.

The 64-bit block problem, in detail

This is the limitation that genuinely matters, and it’s worth understanding rather than taking on faith, because it has nothing to do with key length — a 448-bit Blowfish key doesn’t help at all.

With a 64-bit block, there are only 2^64 possible ciphertext blocks. Under the birthday bound, you expect to see two identical ciphertext blocks after encrypting roughly 2^32 of them — about four billion blocks, or around 32GB of data under a single key. In chaining modes like CBC, that collision isn’t harmless: it leaks the XOR of two plaintext blocks, and an attacker who knows or can influence one of them learns the other. Collect enough traffic and you can recover secrets from an encrypted stream without ever touching the key.

That stopped being theoretical in 2016, when researchers demonstrated this against real deployments of 64-bit block ciphers — recovering authentication tokens from long-lived encrypted connections carrying hundreds of gigabytes of traffic, in both TLS sessions protected by 3DES and VPN tunnels protected by Blowfish. The response across the industry was to retire 64-bit block ciphers from protocols that keep connections open, and to strictly cap how much data any remaining deployment may encrypt under one key.

The practical rule: if a single key will ever protect more than a few gigabytes, or a connection stays open long enough to carry that much, Blowfish is the wrong cipher regardless of how long your key is. Rekeying frequently mitigates the problem, but a 128-bit block cipher removes it entirely.

Comparing Blowfish with Other Algorithms

Blowfish’s position is easiest to understand relative to the ciphers on either side of it — the one it was built to replace, the one that replaced it, and the successor its own designer produced.

  • Against DES — Blowfish is superior in both key size and resistance to differential cryptanalysis. Read more in our DES guide. Note the one thing it didn’t improve on: both ciphers use 64-bit blocks, so Blowfish inherited exactly the structural limit that now constrains it. Our AES vs DES comparison covers how much of a generational shift the move to 128-bit blocks really was.
  • Versus AES — AES boasts larger blocks and better hardware performance, but Blowfish’s flexibility and open design still make it relevant where compatibility or legacy support is needed. See our AES guide for a deeper comparison. On any current processor the performance comparison now favours AES decisively, since AES gets dedicated CPU instructions and Blowfish runs entirely in software.
  • Versus Twofish — Twofish, Schneier’s successor design, builds on Blowfish, addressing its block size limitation and adding more security features at the cost of increased complexity. Learn more in our Twofish guide. If you want a Schneier-designed cipher without the 64-bit block ceiling, Twofish is the direct answer — and Schneier himself has long pointed people toward it rather than Blowfish for new work.

Is Blowfish Encryption Cracked?

There’s a persistent myth that Blowfish has been “cracked.” The reality: no known practical attacks exist against the full 16 rounds. Weak keys and reduced-round variants can be vulnerable in theory, but a properly implemented Blowfish setup remains secure for its intended scope. That said, data-intensive applications should favor ciphers with larger block sizes to future-proof against statistical attacks.

Two caveats are worth stating precisely, since they’re what the myth usually distorts. First, academic work has identified a class of weak keys — keys whose expansion produces duplicate entries within the key-dependent S-boxes — which enables attacks on reduced-round versions of the cipher. These keys are vanishingly rare among randomly generated ones, and the resulting attacks still don’t extend to all 16 rounds. Second, reduced-round Blowfish has been analysed successfully, but that’s routine in cryptanalysis; every serious cipher is attacked round by round, and progress against a fraction of the rounds is how the field measures a design’s safety margin rather than evidence of a break.

So the accurate summary is this: Blowfish is not broken, but it is limited. The reason to move away from it is the 64-bit block ceiling described above, not any weakness in its round function. Conflating the two leads people to the wrong conclusion in both directions — panicking about a cipher that’s mathematically sound, or trusting it with data volumes it was never built to handle.

Real-World Applications

Blowfish’s deployment history splits cleanly into places it has been retired from and one place where it’s still genuinely everywhere.

  • Password hashing via bcrypt — the most significant surviving use, and the one most people encounter without knowing it. bcrypt takes Blowfish’s deliberately expensive key setup and turns it into a feature: the setup is repeated a tunable number of times, so verifying one password stays cheap while testing billions of guesses becomes prohibitively slow. As hardware gets faster, administrators raise the cost factor rather than replacing the algorithm. bcrypt remains a mainstream, recommended password-hashing choice today — note that this uses Blowfish’s key schedule for hashing, not the cipher for encryption, so the 64-bit block limitation is irrelevant here.
  • VPNs — Blowfish-CBC was the long-standing default cipher in widely used open-source VPN software before the switch to AES-GCM. Existing tunnels can still negotiate it for backward compatibility, but it’s no longer the recommended configuration.
  • Legacy SSH and network tools — Blowfish was a standard cipher option in early SSH implementations. Modern versions have removed it from their defaults in favour of AES and ChaCha20.
  • File and disk encryption — a number of open-source archive and file-encryption tools support Blowfish, which is a reasonable fit given that single files rarely approach the per-key data limit.

The pattern is consistent: where Blowfish encrypts streams, it’s been replaced; where it protects bounded amounts of data — or where its slow key setup is the whole point, as in bcrypt — it’s still doing useful work.

Implementing Blowfish Safely

If you’ve concluded Blowfish is right for your situation, the cipher itself is the easy part. Everything around it is where implementations fail.

  1. Generate a strong, random key — use a cryptographic random number generator, never a password or predictable value directly. Despite the 448-bit ceiling, 128 bits or more of genuine entropy is the practical target; longer keys don’t compensate for the block size limit.
  2. Derive keys properly from passwords — if a human-memorable secret is involved, run it through a purpose-built key derivation function first. Feeding a password straight into key expansion gives you a key only as strong as the password.
  3. Choose a secure mode — never ECB, which encrypts identical plaintext blocks to identical ciphertext and leaks structure. CBC and CTR are the sensible options, both requiring a unique, unpredictable IV for every encryption under a given key.
  4. Authenticate the ciphertext — Blowfish provides confidentiality, not integrity. Apply a MAC over the ciphertext and verify it before decrypting. Never invent your own construction for this; use an established encrypt-then-MAC arrangement from a library.
  5. Cap the data per key — set an explicit limit well below the 32GB birthday bound and rotate keys when you reach it. For long-lived connections, rekey on a schedule rather than a total.
  6. Exchange keys with asymmetric cryptography — for anything crossing a network, use public-key methods to establish the session key, as covered in our symmetric and asymmetric encryption guide.
  7. Store keys properly — hardware security modules or a managed key service, never hardcoded in source or configuration.

Use a maintained library — OpenSSL, Crypto++, or the equivalent module for your language — rather than writing the algorithm yourself, and verify whatever you use against the published test vectors before trusting it with real data.

Alternatives and Migration Paths

Should you use Blowfish now?

  • For legacy and compatibility — yes, if mandated or for supporting old systems, provided you respect the per-key data limit.
  • For password hashing via bcrypt — yes. This is a current, recommended practice, not a legacy compromise.
  • For new deployments — prefer AES for new systems due to its stronger security guarantees and broader adoption. Twofish is a reasonable alternative if you specifically want a non-AES cipher with a 128-bit block.

Migration is more involved than swapping a library call, because ciphertext can’t be converted in place — there’s no transformation from Blowfish output to AES output. Every encrypted record has to be decrypted with the old key and re-encrypted with the new one, which means the old key stays live throughout the transition and the process needs the same protection as the data itself.

A few things make that go more smoothly:

  • Tag your ciphertext with an algorithm identifier — if the stored format doesn’t already record which cipher and mode produced it, add that first. Without it, a gradual migration has no way to tell which records have been converted.
  • Run a dual-read period — teach the application to decrypt both formats while writing only the new one, so records can migrate lazily as they’re touched rather than in one high-risk batch.
  • Audit for hardcoded block assumptions — code written against a 64-bit block often bakes in 8-byte padding, IV lengths, or buffer sizes. Those break silently against a 128-bit block cipher.
  • Verify before deleting — confirm the re-encrypted data decrypts correctly before destroying the original, and only then retire the old keys.
  • Leave bcrypt hashes alone — you can’t re-hash a password you don’t have. If you’re moving password storage to a different algorithm, upgrade each hash the next time the user successfully logs in, and keep verifying the old format until they do.

Summary

Blowfish offers a unique balance of speed, flexibility, and proven security. While not recommended for encrypting vast quantities of data due to its block size limits, it remains a trusted choice for legacy systems and smaller-scale data protection needs. Understanding its features, implementation steps, and best practices ensures you take full advantage of what it provides — while avoiding the pitfalls.

The distinction worth carrying away is between a cipher that’s broken and one that’s outgrown its era. Blowfish’s round function has survived thirty years of public analysis without a practical break. Its 64-bit block belongs to the generation it was designed to replace, and that — not any cryptographic weakness — is what rules it out for bulk or streaming encryption today. Meanwhile the property everyone once considered its main drawback, that punishingly slow key setup, turned out to be its most durable contribution: bcrypt still protects passwords with it.

If you’re starting something new, reach for AES. If you’ve inherited Blowfish, you don’t have an emergency — you have a data limit to respect and a migration to plan.

Further reading:

blowfish symmetric-encryption block-cipher