Question 1. Encryption One type of encryption is Row/Column Transposition. Here the string is written into a grid by row

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Question 1. Encryption One type of encryption is Row/Column Transposition. Here the string is written into a grid by row

Post by answerhappygod »

Question 1 Encryption One Type Of Encryption Is Row Column Transposition Here The String Is Written Into A Grid By Row 1
Question 1 Encryption One Type Of Encryption Is Row Column Transposition Here The String Is Written Into A Grid By Row 1 (62.34 KiB) Viewed 31 times
Question 1. Encryption One type of encryption is Row/Column Transposition. Here the string is written into a grid by rows and read out by columns to give the encrypted string. A method to perform this encryption has header as follows: public static String encryptRowColumn (String plaintext, int numColumns) The pseudocode for this method is: Remove spaces from plaintext Calculate numRows required for plaintext If plaintext doesn't fit exactly, pad it with Xs String: cipherText = "" For col = 0 To numColumns - 1 Integer: index = col For row = 0 To numRows - 1 cipherText = cipher Text + plaintext[index] index += numColumns Next row Next col Return cipherText (a) Explain what plaintext and cipherText represent here. (2 marks) 6) Give the code for a method to remove spaces from plaintext. (6 marks) The method header is: public static String removeSpaces (String plaintext) The method should return the string consisting of plaintext without the spaces. Use the following methods of String class: public int length() Returns the length of this string. public char charAt(int index) Retums the char value at the specified index. (©) Explain why plaintext may have to be padded with Xs. (3 marks) (d) Explain how method encryptRowColumn works. Refer to the pseudocode. Give an example to illustrate your answer. (10 marks)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply