Question: 2. [25 pts] Three-rail Cipher Problem In this problem, you will implement a transposition cipher that, instead of dividing the original text into odd and

 2. [25 pts] Three-rail Cipher Problem In this problem, you will

2. [25 pts] Three-rail Cipher Problem In this problem, you will implement a transposition cipher that, instead of dividing the original text into odd and even characters, separates it into three sets of characters. As an example, we will use this 1977 quote by Digital Equipment Corp.president Ken Olson -- "There is no reason anyone would want a computer in their home." (Spaces are represented with the square u-like character.) There is no reason anyone would want a computer in their home. Rail 1: Rail 2: Rail 3: h e S r s O e O a O n n n o da u i t i h 1 U a r n h r o 2 w t t u e m Example three-rail transposition. The resulting encrypted text is produced by reading the text horizontally, i.e., adding the three rails: Rail 1 + Rail 2 + Rail 3 = "Trinrs yeoda cpeitihehesoeoao u naournhro.e annnwlwt mt em" (without the quotes). Requirements Implement the three-rail transposition cipher above, placing your code in the file p4_2.py. Define the functions encrypt (msg:str)-strand decrypt (msg:str)-str. You may define other functions, but these functions must match the interface specified here. The encrypt function should take in the original text and use the three-rail encryption approach described above, returning the encrypted string. The decrypt function should assume that the msg is already encrypted as described above and decrypt it, returning the original text. Examples The following image shows the results of executing the required functions. >>> encrypted = encrypt("There is no reason anyone would want a computer in their home.") >>> encrypted 'Trinrs yeoda cpeitihehesoeo ao u naournhro.e annnwiwt mt e m'. >>> original = decrypt(encrypted) >>> original 'There is no reason anyone would want a computer in their home

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!