Blowfish Encrypt & Decrypt Online | OpenSSL Compatible | Multiple Modes

Encryption
100% client-side. Processed locally in your browser using the Web Crypto API. Nothing is sent to any server.
⚠️ Critical Security: Blowfish uses 64-bit blocks, making it vulnerable to the Sweet32 birthday attack after ~32 GB of data under the same key. Bruce Schneier (the designer) recommends AES-256 for all new projects. This tool is for legacy system compatibility and educational purposes only.

How It Works

What Is Blowfish Encryption?

Blowfish is a symmetric-key block cipher designed by Bruce Schneier in 1993. It uses a variable-length key (32–448 bits) and a 64-bit block size. Blowfish was widely adopted in the 1990s and early 2000s as a fast, patent-free alternative to DES. Its successor, Twofish, was an AES finalist.

This tool provides Blowfish encryption and decryption using the crypto-js library. It supports two output formats: Standard (explicit key 4–56 bytes + 8-byte IV) and OpenSSL Compatible (passphrase with random salt, auto-detecting legacy MD5 and modern SHA-256 key derivation). Five cipher modes (CBC, CFB, OFB, CTR, ECB) and five padding schemes are available. All operations run locally in your browser.

When to Use Blowfish

  • Legacy system compatibility — Decrypting data from older systems that use Blowfish
  • OpenSSL interoperability — Working with systems using OpenSSL's "Salted__" Blowfish format
  • Legacy Chinese systems — Older GBK/GB18030-encoded services that used Blowfish
  • Educational purposes — Understanding the evolution of symmetric encryption
  • When NOT to use — For all new encryption needs, use AES-256-GCM or ChaCha20-Poly1305 instead

Cipher Comparison

AlgorithmKey SizeBlock SizeSecurityStatus
Blowfish32–448-bit64-bitWeak (Sweet32)Legacy only
AES128/192/256-bit128-bitStrongCurrent standard

Cipher Modes

ModeIV RequiredPaddingRecommendation
CBCYes (8 bytes)PKCS7Recommended for block data
CFBYes (8 bytes)No (streaming)Good for streaming data
OFBYes (8 bytes)No (streaming)Similar to CFB, error recovery differs
CTRYes (8 bytes)No (streaming)Parallelizable encryption
ECBNoPKCS7Not recommended — reveals patterns

Standards Compliance

  • Blowfish — Designed by Bruce Schneier (1993), placed in the public domain
  • OpenSSL — Compatible with OpenSSL bf-cbc, bf-cfb, etc. commands
  • NIST — Blowfish is not a NIST-approved algorithm; use AES (FIPS 197) for new systems
  • Sweet32 — CVE-2016-2183 documents birthday attacks on 64-bit block ciphers

Last updated:

Code Examples

Encrypt with Blowfish using well-audited libraries:

JavaScript — crypto-js (Browser)

// Blowfish-CBC encrypt with crypto-js
import CryptoJS from 'crypto-js';

const key = CryptoJS.lib.WordArray.random(16);  // 128-bit key
const iv = CryptoJS.lib.WordArray.random(8);    // 64-bit IV
const ct = CryptoJS.Blowfish.encrypt(
  'secret message', key,
  { iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }
);
console.log('Ciphertext (Base64):', ct.toString());

Python — PyCryptodome

from Crypto.Cipher import Blowfish
import os

key = os.urandom(16)  # 128-bit key
iv = os.urandom(8)    # 64-bit IV
cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
ct = cipher.encrypt(b'secret message!!')  # 16 bytes (padded)
print('Ciphertext (hex):', ct.hex())

Go — golang.org/x/crypto/blowfish

import (
    "crypto/cipher"
    "golang.org/x/crypto/blowfish"
)

key := []byte("your-secret-key!!") // 16 bytes
iv := make([]byte, blowfish.BlockSize) // 8 bytes
block, _ := blowfish.NewCipher(key)
mode := cipher.NewCBCEncrypter(block, iv)
plaintext := []byte("secret message!!")
mode.CryptBlocks(plaintext, plaintext)

Rust — blowfish crate

use blowfish::cipher::{BlockEncrypt, KeyInit};
use blowfish::Blowfish;

let key = b"your-secret-key!!"; // 16 bytes
let cipher = Blowfish::new_from_slice(key).unwrap();
// Use cipher for block-level encryption
// Combine with a mode (CBC, CTR) for full encryption

Node.js — OpenSSL Compatible

const CryptoJS = require('crypto-js');

// OpenSSL-compatible passphrase encryption
const passphrase = 'my-secret-passphrase';
const encrypted = CryptoJS.Blowfish.encrypt(
  'secret message', passphrase,
  { mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }
);
console.log('OpenSSL format:', encrypted.toString());
// Output starts with "U2FsdGVkX1" (Salted__)

Common Pitfalls

⚠️ Sweet32 Birthday Attack: Blowfish's 64-bit block size means that after encrypting ~32 GB of data under the same key, collisions become likely. An attacker can recover plaintext by collecting enough ciphertext. This is why AES (128-bit blocks) replaced Blowfish.
⚠️ Using ECB Mode: ECB encrypts each 8-byte block independently — identical plaintext blocks produce identical ciphertext, revealing data patterns. Always use CBC, CFB, OFB, or CTR mode instead.
⚠️ Short Keys: While Blowfish supports keys from 32 to 448 bits, keys shorter than 128 bits are considered weak. Use at least 128-bit (16-byte) keys for legacy systems.
⚠️ OpenSSL Digest Mismatch: OpenSSL historically used MD5 for key derivation, then switched to SHA-256. This tool auto-detects both, but other implementations may not. If decryption fails, try the other digest.
⚠️ Character Encoding on Decrypt: If decrypted output looks garbled, try a different character encoding (GBK, GB18030, UTF-16LE). The correct encoding will produce readable text.

Security Notes

ℹ️ Migrate to AES: Bruce Schneier (Blowfish designer) officially recommends AES or Twofish for all new projects. Blowfish should only be used for legacy system compatibility.
ℹ️ CBC Mode Is Recommended: For Blowfish, CBC is the most widely supported and compatible mode. It chains blocks together, preventing pattern leakage.
ℹ️ OpenSSL Compatible Auto-Detection: This tool automatically detects whether the ciphertext uses legacy MD5 or modern SHA-256 key derivation, simplifying interoperability with different OpenSSL versions.
ℹ️ IV Must Be Unique: For CBC, CFB, OFB, and CTR modes, the IV must be unique for each encryption operation with the same key. Use the Random button to generate a cryptographically secure IV.

Disclaimer

This tool is provided for educational and legacy compatibility purposes only. Blowfish is not recommended for new encryption projects. For production systems, use AES-256-GCM or ChaCha20-Poly1305. Always validate interoperability with your target platform and follow current cryptographic standards.

Further Reading

Related Concepts

Related Tools

Need modern, secure encryption? Use AES Encrypt/Decrypt instead. For working with legacy DES data, see DES Encrypt/Decrypt. For modern stream cipher encryption, try the ChaCha20 Encrypt/Decrypt tool.

Frequently Asked Questions

What padding should I use?

PKCS7 is the modern default and unambiguously marks the end of the plaintext. Zero padding is common in old C implementations. ANSI X9.23 and ISO 10126 appear in specific legacy banking and financial systems. None means the plaintext is already a multiple of the 8-byte block size. Streaming modes (CFB/OFB/CTR) need no padding at all.

What key length does Blowfish need?

Blowfish accepts variable keys from 4 to 56 bytes (32–448 bits). Keys up to 448 bits were a selling point in 1993, when AES did not exist yet. Longer keys do not compensate for the 64-bit block weakness.

Can I decrypt ciphertext from other tools?

Yes. If the ciphertext starts with "U2FsdGVkX1" (Base64 for "Salted__"), it is OpenSSL format — select "OpenSSL Compatible", enter the passphrase, and the tool decrypts it, auto-detecting both legacy MD5 and modern SHA-256 key derivation. For non-OpenSSL ciphertext, select "Standard" and enter the exact key, IV, mode, and padding used for encryption.

Can it decrypt GBK-encoded Chinese data?

Yes. Legacy Chinese systems (older Java services, domestic software) usually stored text in GBK or GB18030 rather than UTF-8. Switch the Character Encoding selector on decrypt to GBK, GB2312, or GB18030 and the output decodes correctly. UTF-16LE (Windows software) is also supported. The encrypt side supports UTF-8, UTF-16LE, and Latin1 only — browsers cannot encode GBK, so paste the original bytes as hex if you need to reproduce GBK ciphertext.

Which cipher mode should I choose?

Use CBC for most cases — it is the most widely supported and recommended mode. Use CFB or OFB for streaming data where padding is undesirable. Use CTR for parallelizable encryption. Avoid ECB unless you are working with legacy data that requires it.

What character encoding should I select for decryption?

Most modern data uses UTF-8. Legacy Chinese systems typically use GBK or GB18030. Older Windows software may use UTF-16LE. Latin1 (ISO-8859-1) covers Western European languages. If the decrypted output looks garbled, try a different encoding — the correct one will produce readable text.

Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.

More in Encryption