On 07/19/2012 10:04 PM, eryksun wrote:
> On Thu, Jul 19, 2012 at 3:08 PM, Jordan <wolfrage8...@gmail.com> wrote:
<SNIP>
> I'm not an expert with cryptography, but here's a simple XOR example:
>>>> from itertools import cycle
>>>> text = b'Mary had a little lamb.'
>>>> key = b'1234'
>>>> cypher = bytes(x^y for x,y in zip(text, cycle(key)))
>>>> cypher
> b'|SAM\x11ZRP\x11S\x13XXFGXT\x12_U\\P\x1d'
>>>> text2 = bytes(x^y for x,y in zip(cypher, cycle(key)))
>>>> text2
> b'Mary had a little lamb.'
Hmm interesting, I am reading up on on itertools.cycle() and zip now.
Thanks always more than one way to solve a problem.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor