[Tutor] Iterate over letters in a word

Matthew Webber m_webber_sydney at yahoo.com.au
Tue Mar 14 21:53:08 CET 2006


As a side note, remember that that xor-ing a key with a message is trivial
to break (it's just a variation on the Vigenere cipher first published in
1568). So don't use if for any real applications.

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of Steve Nelson
Sent: 14 March 2006 15:29
To: tutor at python.org
Subject: [Tutor] Iterate over letters in a word

Hello,

I'm trying to work on some programs to help me understand ciphers and
ultimately cryptography.  I've understood so far, that a simple form
of bit-level cryptography is to split the original message into chunks
the same length as a 'key' and then do an xor.  I'm trying to keep
this really simple so I can understand from first principles - so eg:

"Hello Tutors!" could be split into:

"Hell" "o Tut" "ors!"

and xor'd with "beer"

I think I understand how xor works (thanks to an earlier post) but I'm
not sure how to iterate over each letter in a string.  What is the
recommended way to do this?

Thanks,

S.



More information about the Tutor mailing list