Nov-13-2017, 10:09 PM
(Nov-13-2017, 09:27 PM)Larz60+ Wrote: OK, I'll print out the algorithm from a crypto site, and see if I can follow your code
to find the error.
I'll work on this after dinner tonight, but probably will not have an answer until tomorrow.
One suggestion. I don't don't know if you use an IDE for editing your code, but if so and
it has a debugger, you can run your code step by step, watching selected variables as they change.
I use PyCharm and it has a very good debugger. Most IDE's do.
By the way, your code is very neat and well organized,
perhaps you have found your career.
Thank you very much for your help, and also your remark! Yes, I hope I may be able to start a career with programing, just dont know really where to start... Summer jobs would be complicated/boring seen as I dont have the level..
But back to our code: I use PyScripter for programming and it does and a debugger. I used it a couple of times until now, but dont think it can help much, because the error isn't in the code, but in the philosophy...
I do get a decripted message, but it does not correspond with my input... Here is my problem.
I am guessing I have to find the right list for eversing the process, but it didn't work out so far..
What I have done until now, which I copied from the library you sent me is:
def starter(): """Converts our last character of the inputted text into a cipher""" global ENCMESS,c,text,x,Rotor1 x = text[len(text)-1] for cha in char: ENCMESS+=1 if x==cha: break def coder(seq,rev,m): """Acts as our rotors""" global ENCMESS if rev==0 or rev==2: ENCMESS =(ENCMESS+m)%26 ENCMESS = seq[ENCMESS-1]%26 ENCMESS =(ENCMESS-m)%26 elif rev==1: lst=["empty"]*26 ENCMESS =(ENCMESS+m)%26 for i,v in enumerate(seq): lst[v-1] = i ENCMESS = lst[ENCMESS-1]%26 ENCMESS =(ENCMESS-m)%26 def letters(): """Converts the ciher back to a letter""" global ENCMESS ENCMESS = char[ENCMESS-1] starter() coder(Rotor1,0,c) coder(Rotor2,0,d) coder(Rotor3,0,e) coder(Mirror,2,c) coder(Rotor3,1,e) coder(Rotor2,1,d) coder(Rotor1,1,c)It still doesn't print the right output.. M< supposition from the beginning is still up, while Ia m thinking that it could be the counter switching letters one too much or not enough.. But I'll see and hopoe what you can find out!
Thank you!