Caesar chiffer bug fix

master
E. Almqvist 5 years ago
parent 362cbff910
commit fea7c17c10
  1. 11
      caesar.py

@ -25,13 +25,14 @@ for char in txt_list: # loop through all of the chars
charindex = charindex + 1 charindex = charindex + 1
index = alphabet[in_alphabet].index(char) index = alphabet[in_alphabet].index(char)
print("Decrypting char-index: " + str(charindex) + " (" + char + ")") print("Decrypting char-index: " + str(charindex) + " (" + char + ":" + str(index) + ")")
index = index + in_key # shift the alphabet index = index + in_key # shift the alphabet
while( index > alen - 1 ): #cycle through the alphabet while( index > alen - 1 ): #cycle through the alphabet
print("Alphabet cycle") index = index - alen
index = index - (alen - 1) print(" Alphabet cycle, index: " + str(index))
decryp_list[charindex] = alphabet[in_alphabet][index] charDe = alphabet[in_alphabet][index]
decryp_list[charindex] = charDe
print( "Output: " + listToString(decryp_list) ) print( "Output: " + listToString(decryp_list) )

Loading…
Cancel
Save