Current File : //usr/lib64/python2.7/site-packages/Crypto/Cipher/Blowfish.pyo |
�
Bd\Rc @ s� d Z d Z d d l m Z d d l m Z d e j f d � � YZ d � Z d Z d Z d
Z
d Z d Z d
Z
d Z d Z e d d � Z d S( s� Blowfish symmetric cipher
Blowfish_ is a symmetric block cipher designed by Bruce Schneier.
It has a fixed data block size of 8 bytes and its keys can vary in length
from 32 to 448 bits (4 to 56 bytes).
Blowfish is deemed secure and it is fast. However, its keys should be chosen
to be big enough to withstand a brute force attack (e.g. at least 16 bytes).
As an example, encryption can be done as follows:
>>> from Crypto.Cipher import Blowfish
>>> from Crypto import Random
>>> from struct import pack
>>>
>>> bs = Blowfish.block_size
>>> key = b'An arbitrarily long key'
>>> iv = Random.new().read(bs)
>>> cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
>>> plaintext = b'docendo discimus '
>>> plen = bs - divmod(len(plaintext),bs)[1]
>>> padding = [plen]*plen
>>> padding = pack('b'*plen, *padding)
>>> msg = iv + cipher.encrypt(plaintext + padding)
.. _Blowfish: http://www.schneier.com/blowfish.html
:undocumented: __revision__, __package__
s $Id$i����( t blockalgo( t _Blowfisht BlowfishCipherc B s e Z d Z d � Z RS( s Blowfish cipher objectc O s t j j | t | | | � d S( sZ Initialize a Blowfish cipher object
See also `new()` at the module level.N( R t BlockAlgot __init__R ( t selft keyt argst kwargs( ( s<