Question: Need help with python code. Decryption is not yielding the correct result, problem is in the decrypt function, need help. import sys # Global constants

Need help with python code. Decryption is not yielding the correct result, problem is in the decrypt function, need help.
import sys
# Global constants
NUM_ROWS =6
NUM_COLS =4
ROW_TRANSPOSITION =[3,5,0,2,1,4]
COL_TRANSPOSITION =[3,2,0,1]
def encrypt(text):
table =[['' for _ in range(NUM_COLS)] for _ in range(NUM_ROWS)]
index =0
for i in range(NUM_ROWS):
for j in range(NUM_COLS):
if index len(text):
table [i][j]= text[index]
index +=1
else:
table [i][j]=?''
# Transpose rows
table =[table [i] for i in ROW_TRANSPOSITION]
# Transpose columns
table =[list(row[i] for i in COL_TRANSPOSITION) for row in table]
# Output encrypted text
for row in table:
print(""'.join(row), end='')
def decrypt(text):
table =[['' for _ in range(NUM_COLS)] for _ in range(NUM_ROWS)]
index =0
# Populate the table column by column
for j in range(NUM_COLS):
for i in range(NUM_ROWS):
table index]
index +=1
# Reverse column transposition
table =[list(''.join(row[i] for row in table)) for i in COL_TRANSPOSITION]
# Reverse row transposition
decrypted_text =''.join(''.join(row) for row in table)
print (decrypted_text)
def main():
if sys.argv[1] not in ('-e','-d'):
print("Usage: python
script.py -e |-d ====
 Need help with python code. Decryption is not yielding the correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!