All Projects → keybase → python-twofish

keybase / python-twofish

Licence: BSD-3-Clause License
Bindings for the Twofish implementation by Niels Ferguson

Programming Languages

c
50402 projects - #5 most used programming language
objective c
16641 projects - #2 most used programming language
python
139335 projects - #7 most used programming language

python-twofish

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].