Question: CSC 110 - Homework 7 - Cryptography In class we wrote a Python function to encrypt a message using the Caesar Cipher. For this homework
CSC 110 - Homework 7 - Cryptography
-
In class we wrote a Python function to encrypt a message using the Caesar Cipher. For this homework assignment, you will modify the Caesar cipher by shifting each letter in the plaintext by the given shift value plus the position of the letter in the plaintext. For example, if the we have:
plaintext = 'hello'
shift = 18
the plaintext would be shifted as follows:
'h' (7) - shifted by 18 + 0 ==> 25 ('z')
'e' (4) shifted by 18+1 ==> 23 ('x')
'l' (11) shifted by 18+2 ==> 31 % 26 = 5 ('f')
'l' (11) shifted by 18+3 ==> 32 % 26 = 6 ('g')
'o' (14) shifted by 18+4 ==> 36 mod 26 = 10 ('k')
the ciphertext would be 'zxfgk'
Write a function that takes the plaintext and the shift value as parameters and returns the ciphertext using this modified Caesar cipher algorithm Write another function that deciphers the modified Caesar cipher algorithm. This second function will take the ciphertext and the shift value as parameters and return the plaintext. The output of your functions should look something like this:

-
We learned in class about the polyalphabetic cipher that uses a word as the key for shifting the plaintext and creating ciphertext. When the keyword is smaller than the plaintext, the keyword is repeated. A variation on this algorithm uses the keyword to shift the plaintext, and if the keyword is smaller than the plaintext, the keyword is used, followed by the keyword shifted by 1, and then the keyword again until all letters in the plaintext are shifted. For example, given the following plaintext and keyword:
plaintext = computerscience
keyword = code
we would encrypt the plaintext by shifting each letter by the corresponding letter of the keyword followed by the keyword shifted by 1. In this example, the keyword shifted by 1 would be:
dpef
So the full keyword would be
codedpef
And that would repeat to fit the length of the plaintext as follows:
computerscience
codedpefcodedpe
c would be shifted by c, o would be shifted by o, m would be shifted by d, p would be shifted by e, the u would be shifted by e, and so on.
The resulting ciphertext of the example above would be:
ecptxiiwuqliqri
Write a function that implements this variation on the polyalphabetic cipher. The parameters of the function will be the plaintext and the keyword. The function will return the ciphertext. Write another function that deciphers this variation of the polyalphabetic cipher. Test your program using at least the following examples:

***PLEASE MAKE SURE THAT THE CIPHER SHIFT IS BY 1 AND THAT TWO FUNCTIONS ARE CREATED, TO ENCODE AND DECODE***
>>> caesarPlus('hello',18) 'zxfgk' >>> unCaesarPlus('zxfgk',18) 'hello' >>> caesarPlus('computerscience',9) "lyxbhhthjubyiyb' >>> unCaesarPlus('lyxbhhthjubyiyb',9) 'computerscience' >>> caesarPlus('bbbbbbb', 8) jklmnop' >>> unCaesarPlus('jklmnop', 8) "bbbbbbb' | >>> >>> polyShifted('computerscience', 'code') 'ecptxi iwuqligri' >>> unPolyShifted('ecptxi iwuqliqri', 'code') 'computerscience' >>> polyShifted('theroomwhereithappens','burr') 'ubviqjeoiyivkozsqjveu' >>> unPolyShifted('ubviqjeoiyivkozsqjveu','burr') 'theroomwhereithappens' >>> polyShifted('aaaaaaaaaa','bbb') "bbbcccbbbc' >>> unPolyShifted('bbbcccbbbc','bbb') 'aaaaaaaaaa' >> |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
