Question: I am using a bash file to collect an output, yet the output is showing a ton of plaintext when it should actually just show
I am using a bash file to collect an output, yet the output is showing a ton of plaintext when it should actually just show this output:
Compile of pa succeded.
Case #
Case # complete
Case #
Case # complete
Case #
Case # complete
Case #
Case # complete
Case #
Case # complete
The output that IS being shown is provided in the image. How do I make it so all the plaintext doesn't show at all? My code is provided below:
import sys
#Read the key file and then return the size of the key file matrix and its numbers
def readkeyFilekeyFile:
with openkeyFiler as file:
n intfilereadlinestrip
keyMatrix
for in rangen:
row listmapint file.readlinestripsplit
keyMatrix.appendrow
return n keyMatrix
#Convert the plaintext file into lowercase
def readplaintextFileplaintextFile:
with openplaintextFiler as file:
plainText file.readlower
plainText joinfilterstrisalpha, plainText
return plainText
#Pad the plaintext file and also remove any numbers from it
def padplainTextplainText n:
remainder lenplainText n
if remainder :
padding n remainder
plainText x padding
return plainText
#Encrypt the plaintext file into a matrix
def encryptplainText keyMatrix:
n lenkeyMatrix
cipherText
for i in range lenplainText n:
block ordchar orda for char in plainTexti:in
encryptBlock sumkeyMatrixjk blockk for k in rangen orda for j in rangen
cipherText joinchrchar for char in encryptBlock
return cipherText
#Write the output of the plaintext file
def displayoutputkeyMatrix plainText, cipherText:
print
Key Matrix:"
for row in keyMatrix:
printjoinstrnum for num in row
print
Plaintext:"
for i in range lenplainText:
printplainTexti:i
print
Ciphertext:"
for i in range lencipherText:
printcipherTexti:i
#Display the output of the plaintext file
def main:
if lensysargv:
printUsage: python papy
return
keyFile sysargv
plaintextFile sysargv
n keyMatrix readkeyFilekeyFile
plainText readplaintextFileplaintextFile
plainText padplainTextplainText n
cipherText encryptplainText keyMatrix
displayoutputkeyMatrix plainText, cipherText
if namemain:
main
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
