Skip to main content

Bindings for the Twofish implementation by Niels Ferguson libtwofish-dev.

Compatible with Python 2.6, 2.7 and 3.3.

The library performs a self-test at each import.

Installation

pip install twofish

Usage

Create a twofish.Twofish instance with a key of length ]0, 32] and then use the encrypt and decrypt methods on 16 bytes blocks.

All values must be binary strings (str on Python 2, bytes on Python 3)

[WARNING] this should be used in a senseful cipher mode, like CTR or CBC. If you don’t know what this mean, you should probably usa a higher level library.

Example

>>> from twofish import Twofish
>>> T = Twofish(b'*secret*')
>>> x = T.encrypt(b'YELLOWSUBMARINES')
>>> print(T.decrypt(x).decode())
YELLOWSUBMARINES

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twofish-0.3.0.tar.gz (26.0 kB view details)

Uploaded Source

File details

Details for the file twofish-0.3.0.tar.gz.

File metadata

  • Download URL: twofish-0.3.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for twofish-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b09d8bb50d33b23ff34cafb1f9209f858f752935c6a5c901efb92a41acb830fa
MD5 d7d22f16dc4ffa0e3ae2200654033abe
BLAKE2b-256 82b49eb026a8e62a04512435d3de25c93f7bda51c8b8c7991c1c0be70b5115a6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page