The `twofish` library provides Python bindings for a C implementation of the Twofish symmetric key block cipher, designed by Niels Ferguson. Twofish is a 128-bit block cipher supporting key sizes up to 256 bits, and was a finalist in the AES competition. The current version is 0.3.0, with the last PyPI release in 2013, and the official GitHub repository was archived in January 2025, indicating it is no longer actively maintained.
pip install twofishVerified import paths — ran on the pinned version, not inferred.
This example demonstrates basic encryption and decryption of a single 16-byte block using a 128-bit key. Note that this library explicitly handles only 16-byte blocks, and higher-level cipher modes (like CBC or CTR) must be implemented externally or by using a different library.
Consider migrating to a actively maintained cryptographic library (e.g., `cryptography` or `PyCryptodome`) that provides Twofish or other robust ciphers with full mode support.
For encrypting data larger than 16 bytes or variable-length messages, you must manually implement a secure block cipher mode and appropriate padding. Using the raw block cipher directly for more complex data can lead to severe security vulnerabilities. It is highly recommended to use a more comprehensive cryptographic library that handles these complexities for you.
Ensure your encryption key is generated securely and precisely matches one of the supported lengths (16, 24, or 32 bytes) before passing it to the `Twofish` constructor.
For modern Python development, use alternative libraries like `cryptography` or `PyCryptodome`, which offer broad compatibility and active maintenance for Twofish and other cryptographic primitives.
No dependency data recorded yet.