Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Rotor turn later than expect #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions Code/Enigma Final - Complete Version/EnigmaFinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def update3(x):
exportRotors=[]
helpStatus = False
finalmsg=[]
countshift = 0

#TODO
#shift to a characte based model?
#funcs. for rotor 4 and 5
Expand Down Expand Up @@ -228,7 +230,7 @@ def rotor1(mssg):
for char in mssg:

if char in alphabetlist:
changedletter=rotor1listTemp[alphabetlist.index(char)]
changedletter=rotor1listTemp[(alphabetlist.index(char) - abs(counts1 - countm1)) % 26]
postr1.append(changedletter)

reverse=True
Expand All @@ -238,7 +240,7 @@ def rotor1(mssg):
for char in mssg:

if char in alphabetlist:
changedletter=alphabetlist[rotor1listTemp.index(char)]
changedletter=alphabetlist[(rotor1listTemp.index(char) + abs(counts1 - countm1)) % 26]
postr1.append(changedletter)
print("r1",postr1)
rotor2(postr1)
Expand All @@ -251,7 +253,7 @@ def rotor2(mssg):
for char in mssg:

if char in alphabetlist:
changedletter=rotor2listTemp[alphabetlist.index(char)]
changedletter = rotor2listTemp[(alphabetlist.index(char) - abs(countm1 - countf1)) % 26]
postr2.append(changedletter)

print("r2",postr2)
Expand All @@ -260,17 +262,20 @@ def rotor2(mssg):
for char in mssg:

if char in alphabetlist:
changedletter=alphabetlist[rotor2listTemp.index(char)]
changedletter=alphabetlist[(rotor2listTemp.index(char) + abs(countm1 - countf1)) % 26]
postr2.append(changedletter)
print("r2",postr2)
rotor3(postr2)

def rotor3(mssg):
global first, countshift
global reverse
postr3=[]

if reverse==False:
shift()
for char in mssg:
countshift += 1
test=[]
if char in alphabetlist:
changedletter=rotor3listTemp[alphabetlist.index(char)]
Expand All @@ -280,7 +285,8 @@ def rotor3(mssg):
print("r3inloop postr3andTest",postr3,test)
print("r3list is now",rotor3listTemp)
rotor2(test)
shift()
if countshift != len(mssg):
shift()

#print("r3 (rev F) Finally (except running PB-the mssg is)",postr3)
#rotor2(postr3)
Expand Down Expand Up @@ -324,8 +330,9 @@ def plugboard(mssg,lstplugboard1=dfltPB1,lstplugboard2=dfltPB2):
#set everything to initial position so it works again for next character in for loop in rotor 3
reverse=False

def code():
global finalmsg, countf, countm, exportCounter, exportRotors
def code(*event):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used entry.bind("<Return>", code),
so you need to specify a optional parameter

global finalmsg, countf, countm, exportCounter, exportRotors, countshift
countshift = 0
#rotorinput=list(input("Enter initial rotor settings for rotors-L,M and R:"))
omssg= entryvar.get()
omssg= omssg.upper()
Expand Down