Currently working on the issue of transposition. So far, I mean that the user enters a message, and this message is encrypted in a list, as shown below:
['BC', 'DE', 'DE', 'DA', 'FD', 'DD', 'BE', 'FE', 'DA', 'EA', 'FE', 'BC']
What I have for the next stage of encryption puts this in a table with the key entered by the user. Therefore, if the user enters "CODE", he displays this:
2: Enter the keyword for final encryption: code
C O D E
['B', 'C', 'D', 'E']
['D', 'E', 'D', 'A']
['F', 'D', 'D', 'D']
['B', 'E', 'F', 'E']
['D', 'A', 'E', 'A']
['F', 'E', 'B', 'C']
The next step is to take each value of each column and print the values corresponding to its column alphabet . So my expected result:
C D E O
['B', 'D', 'E', 'C']
['D', 'D', 'A', 'E']
['F', 'D', 'D', 'D']
['B', 'F', 'E', 'E']
['D', 'E', 'A', 'A']
['F', 'B', 'C', 'E']
The problem I am facing is to figure out how to put each of the values in the corresponding column and print them.
Here is what I still have:
def encodeFinalCipher():
matrix2 = []
key = list(keyword.upper())
firstEncryptionString = ''.join(str(x) for x in firstEncryption)
keywordList = list(firstEncryptionString)
for x in range(0,len(keywordList),len(keyword)):
matrix2.append(list(keywordList[x:x+len(keyword)]))
print (' %s' % ' '.join(map(str, key)))
for letters in matrix2:
print (letters)
unOrderedMatrix = [[matrix2[i][j] for i in range(len(matrix2))] for j in range(len(matrix2[0]))]
for index, item in enumerate (unOrderedMatrix):
print("\n",index, item)
index = sorted(key)
print(index)
I get the output of a sorted key:
['A', 'K', 'M', 'R']
, , , ? , , :
print(unOrderedMatrix[0])
.
. Python