skillfed

twofish

Bindings for the Twofish implementation by Niels Ferguson

twofish v0.3.0 462.6K downloads/30d#6,525 on PyPI28
Permissive license 3-clause BSD Abandoned released

What it is and what it does

Twofish is a Python wrapper around the Twofish block cipher, a symmetric encryption algorithm designed by Niels Ferguson. It exposes a simple API: create a Twofish instance with a binary key (0–32 bytes), then call encrypt() and decrypt() on 16-byte blocks. The library performs a self-test on import to verify the underlying C implementation.

This is a low-level cryptographic primitive, not a complete cipher system. The documentation explicitly warns that it must be used within a proper cipher mode (CTR, CBC, etc.) to be secure; using it directly on plaintext is cryptographically unsafe. The package is unmaintained since 2013 and archived, with no support for modern Python versions beyond 3.3.

Use it for:

  • Legacy system integration where Twofish is mandated by existing protocols or data formats
  • Educational exploration of block cipher mechanics and symmetric encryption primitives
  • Decryption of historical data encrypted with Twofish in a supported cipher mode

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides Python bindings to the Twofish block cipher for encrypting and decrypting 16-byte blocks with keys up to 32 bytes.

No. The package is abandoned, unmaintained since 2013, and documented only for end-of-life Python versions (2.6–3.3). Modern Python compatibility is unverified. High install friction (compiled C extension + system library) and the explicit warning that it requires external cipher-mode wrapping make it unsuitable for new projects. Use a maintained cryptography library like cryptography or PyCryptodome instead.

Install

twofish on PyPI

pip

pip install twofish

uv

uv add twofish

poetry

poetry add twofish

Installing twofish

Before you install

High install friction: the package requires a compiled C extension and the libtwofish-dev system library. The project is archived and unmaintained since 2013, with no updates for over a decade. Compatibility claims are limited to Python 2.6, 2.7, and 3.3—all end-of-life versions.

License in practice

Licensed under 3-clause BSD (permissive), allowing commercial and private use with attribution and liability disclaimer. No restrictions on redistribution or modification.

Quickstart

pip install twofish

from twofish import Twofish
T = Twofish(b'*secret*')
encrypted = T.encrypt(b'YELLOWSUBMARINES')
decrypted = T.decrypt(encrypted)

Requires libtwofish-dev system library installed; high compilation friction. Designed for Python 2.6–3.3; compatibility with modern Python versions is unverified.

Verify before relying

  • Whether the package compiles and runs on Python 3.8 or later (only 3.3 is documented)
  • Current status of the underlying Niels Ferguson Twofish implementation and any known cryptographic weaknesses
  • Whether libtwofish-dev is available in current Linux distributions or requires manual installation

Package facts

License 3-clause BSD (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance abandoned — 4,655 days since the last release
Last repo commit (repository archived)
First released
Downloads 462,586/month — #6,525 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: twofish-0.3.0.tar.gz

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3.3Topic :: Security :: CryptographyTopic :: Software Development :: Libraries

Tags

twofish encryption pythonblock cipher bindingssymmetric key cryptographytwofish decrypt encryptcryptographic library pythonniels ferguson twofish
abandonedlegacy-crypto

More Libraries packages