Question: Part I: The Up/Down Cipher: Encryption Algorithm (20 points) Write a function updown encrypt that takes the following arguments, in this order . plaintext: a
Part I: The Up/Down Cipher: Encryption Algorithm (20 points) Write a function updown encrypt that takes the following arguments, in this order . plaintext: a plaintext string containing letters, digits and spaces that will be encrypted enum.rows: the number of rows that will be used in the encryptioe process Here's how the up/down cipher works. First, take a plaintext string and start draw ing characters from it, placing the first num.rows of characters into the first column of a grid from up to down. We assame here that the grid has num.rows rows in it. Then take the next num.rows characters, placing them into the second column of the grid in reverse order, from down to up. Continue in this fashion, drawing characters from the plaintext string until you run out of characters, alternating between placing them from up to-down and down-to-up. With some arithmetic CSE 101-Fall 2017 Homework #4 Page 1 you should be able to figure out exactly how many columms your grid will need to store all the characters from plaintext As an example, suppose we want to encrypt the string 'ABCDEFGHI JKLNNOPORSTUvw with num.rows 5. The characters would be placed into a grid as follows (the arrows indicae the direction that the letters are written to the grid BILSV CHMRW DGNO EFOP we fill the last column If all characters from the plaintext are placed into the grid but the last column is incomplete, with i symbols: AJKTU BILSV CHMRW EFOP Next, take each row of characters, from left to right, and concatenate them to generate the final, encrypted string. For the example above, the final encrypted string would be: AJKTU + BILSV + CHHRN + DGNQ Here's another example: plaintext . STONYBROOKU NIV, Insert the characters into the grid TRK OBUV NYNI Insert symbols into the last column, as necessary so TRK% NYNI Concatenate the rows of characters together to generate the final, encrypted string: S0O TRKBOBUVNYNI Nete: nun.rows ast be greater than zero. In the case that num.rows plaintext. In the case that plaintext 0, your function should return string of num.rows is an empty string, your function should return a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
