twofish
Bindings for the Twofish implementation by Niels Ferguson
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 twofishuv
uv add twofishpoetry
poetry add twofishInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
xxteaxxtea is a Python extension that implements the…
permissive · top 15,000 on PyPI
pyDesPure Python implementation of DES and Triple…
permissive · top 15,000 on PyPI
pyaesPure-Python implementation of AES encryption…
permissive · top 5,000 on PyPI
pyAesCryptEncrypts and decrypts files and binary streams…
permissive · top 15,000 on PyPI
pyscryptA pure-Python implementation of the scrypt…
permissive · top 15,000 on PyPI
py3rijndaelpy3rijndael provides a pure-Python…
permissive · top 15,000 on PyPI
pyragepyrage provides Python bindings to the Rust…
permissive · top 15,000 on PyPI
aes-pkcs5Provides AES encryption and decryption with…
permissive · top 15,000 on PyPI
pqcryptoProvides Python bindings to post-quantum…
permissive · top 15,000 on PyPI
kasa-cryptProvides fast encryption and decryption…
permissive · top 15,000 on PyPI