ó
Â/¾Oc           @   sQ   d  Z  d Z d d l m Z d d
 d „  ƒ  YZ d „  Z d Z e d d ƒ Z d	 S(   sð   XOR toy cipher

XOR is one the simplest stream ciphers. Encryption and decryption are
performed by XOR-ing data with a keystream made by contatenating
the key.

Do not use it for real applications!

:undocumented: __revision__, __package__
s   $Id$iÿÿÿÿ(   t   _XORt	   XORCipherc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   XOR cipher objectc         O   s:   t  j | | | Ž |  _ |  j j |  _ |  j j |  _ d S(   sU   Initialize a XOR cipher object
        
        See also `new()` at the module level.N(   R    t   newt   _ciphert
   block_sizet   key_size(   t   selft   keyt   argst   kwargs(    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyt   __init__(   s    c         C   s   |  j  j | ƒ S(   sñ   Encrypt a piece of data.

        :Parameters:
          plaintext : byte string
            The piece of data to encrypt. It can be of any size.
        :Return: the encrypted data (byte string, as long as the
          plaintext).
        (   R   t   encrypt(   R   t	   plaintext(    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyR   0   s    	c         C   s   |  j  j | ƒ S(   só   Decrypt a piece of data.

        :Parameters:
          ciphertext : byte string
            The piece of data to decrypt. It can be of any size.
        :Return: the decrypted data (byte string, as long as the
          ciphertext).
        (   R   t   decrypt(   R   t
   ciphertext(    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyR   ;   s    	(   t   __name__t
   __module__t   __doc__R
   R   R   (    (    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyR   %   s   		c         O   s   t  |  | | Ž S(   sÑ   Create a new XOR cipher

    :Parameters:
      key : byte string
        The secret key to use in the symmetric cipher.
        Its length may vary from 1 to 32 bytes.

    :Return: an `XORCipher` object
    (   R   (   R   R   R	   (    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyR   F   s    
i   i    N(    i!   (	   R   t   __revision__t   Crypto.CipherR    R   R   R   t   xrangeR   (    (    (    s0   lib/python2.7/site-packages/Crypto/Cipher/XOR.pyt   <module>   s   !	