Answer the question
In order to leave comments, you need to log in
How to implement the double permutation algorithm?
It is necessary to implement the input of the original text and the output of the encrypted, and vice versa for decryption.
Briefly about the algorithm:
The key to the double permutation cipher is the sequence of column numbers and row numbers of the source table (in our example, the sequences are 4132 and 3142, respectively).
I'm starting to program, so I'll be glad to explain.
s = [list(map(str,input().split())) for i in range (4)]
s[0], s[1] = s[1], s[0]
s[1], s[3] = s[3], s[1]
s[2], s[3] = s[3], s[2]
' '.join(str(x) for x in s)
s[0][0], s[0][1] = s[0][1], s[0][0]
s[0][1], s[0][3] = s[0][3], s[0][1]
s[1][0], s[1][1] = s[1][1], s[1][0]
s[1][1], s[1][3] = s[1][3], s[1][1]
s[2][0], s[2][1] = s[2][1], s[2][0]
s[2][1], s[2][3] = s[2][3], s[2][1]
s[3][0], s[3][1] = s[3][1], s[3][0]
s[3][1], s[3][3] = s[3][3], s[3][1]
print (' '.join(str(x) for x in s))
input ("Press Enter")
Answer the question
In order to leave comments, you need to log in
def decode(text, xkeys, ykeys):
return ''.join(text[4*(y-1)+(x-1)] for y in ykeys for x in xkeys)
print decode(u'ТЮАЕООГМРЛИПОЬСВ', (4,1,3,2), (3,1,4,2))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question