Need to add to ord and convert to chr

mchitti at my-deja.com mchitti at my-deja.com
Sun Nov 5 15:42:18 EST 2000


Trying to teach myself python, would appreciate any help.

I have a long string of letters (a caesar cipher) which I chop up,
convert to ord values and stick into a list.  I need to be able to add
an arbitrary interger to the ord values and then convert back to char.
This should allow me to brute force the cipher if my logic is good.

TIA


Code I have follows....using python 1.5.2



#!/usr/bin/python

position = 0
message =
'qfoukwucpujlukfdsjfdoujoswubepswsbipnqnjqfouksdlnepsaipuoujosdqfzwuobsq
ubqsjfdnbbukobsqfkfhjubskhflskcfjwnkofkwuyshsbnudbsbpomswshsksblfkyshfds
wfkwuwubtndhsdfofdksdejuuducneskpofjhslsosjcukngujfujsdopsljfgpdsbukxlpq
fipukpopchnjopsdwfbskukljubbskobsqsdjuyfduksbsepsejnkopsdwfbfkujsbukkpud
sdqujfdnoskwusbmubnqfoukwucpujlukfdsjfdoujoswubepswsbipnqnj'

loop = len(message)

while loop:
        decode = map(ord,message[position]),
        print decode
        position = position + 1
        loop = loop - 1


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list