Crypto.Cipher.ARC4, bust or me doing something wrong?

Michael Sparks michaels at rd.bbc.co.uk
Wed Sep 21 09:23:58 CEST 2005


Michael J. Fromberger wrote:
...
> Since ARC4 is a stream cipher, the keystream changes over time -- with
> ARC4, after each character enciphered.  To decrypt successfully, you
> need to make sure the decrypting keystream exactly matches the
> encrypting one.
...
>>>> from Crypto.Cipher import ARC4 as cipher
>>>> enc = cipher.new("abcdefgh")
>>>> dec = cipher.new("abcdefgh")
>>>> x = enc.encrypt("This is some random text")
>>>> x
> "\x05o\xd5XH|\xa4\xfc\xf7z\xecd\xe92\xfb\x05rR'\xbf\xc0F\xfc\xde"
>>>> y = dec.decrypt(x)
>>>> y
> 'This is some random text'
>>>> enc.decrypt(x)
> 'M|[bI\x1ciG6A]\x13Hz\xb0\x19\xca\xf1-\x9a\x1a2\x9e%'
> 
> I hope this helps clear up your confusion.

Hi Michael,


Thanks for this, much appreciated. 


Michael
-- 
Michael.Sparks at rd.bbc.co.uk, http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.




More information about the Python-list mailing list