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
NUMROWS
NUMCOLS
ROWTRANSPOSITION
COLTRANSPOSITION
def encrypttext:
table for in rangeNUMCOLS for in rangeNUMROWS
index
for in rangeNUMROWS:
for in rangeNUMCOLS:
if index lentext:
table ij textindex
index
else:
table
# Transpose rows
table table i for in ROWTRANSPOSITION
# Transpose columns
table listrowi for in COLTRANSPOSITION for row in table
# Output encrypted text
for row in table:
printjoinrow end
def decrypttext:
table for in rangeNUMCOLS for in rangeNUMROWS
index
# Populate the table column by column
for in rangeNUMCOLS:
for in rangeNUMROWS:
table index
index
# Reverse column transposition
table listjoinrowi for row in table for in COLTRANSPOSITION
# Reverse row transposition
decryptedtext joinjoinrow for row in table
print decryptedtext
def main:
if sysargv not in ed:
printUsage: python
script.py e d
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
