https://github.com/keybase/python-twofish
Bindings for the Twofish implementation by Niels Ferguson
https://github.com/keybase/python-twofish
Last synced: about 2 months ago
JSON representation
Bindings for the Twofish implementation by Niels Ferguson
- Host: GitHub
- URL: https://github.com/keybase/python-twofish
- Owner: keybase
- License: bsd-3-clause
- Archived: true
- Created: 2013-10-31T03:06:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-02-27T19:33:14.000Z (over 3 years ago)
- Last Synced: 2025-04-09T12:17:09.774Z (3 months ago)
- Language: C
- Size: 238 KB
- Stars: 26
- Watchers: 13
- Forks: 18
- Open Issues: 9
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
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.
.. _libtwofish-dev: http://packages.debian.org/sid/libtwofish-dev
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