Question: In this step well introduce a variation to the Caesar cipher, resulting in a new cipher called the CS8 Cipher. It will be more secure
In this step well introduce a variation to the Caesar cipher, resulting in a new cipher called the CS8 Cipher. It will be more secure since the offset defined by the key will still be constant, but sometimes the shift will be a forward shift and other times it will be a backward shift.
Whether the shift is forward or backward will be dictated by the binary representation of the key, which we will call the binary key. For example, a value of 2 is represented in binary as 10, i.e., two bits containing 1 followed by 0. At each step of the encryption, the algorithm will look at the next bit of the binary key. If it is 1, the shift will be forward, and if it is 0, the shift will be backward. After two characters, we will be at the end of the binary representation of the key, so we will need to start from the beginning of it.
Here are the new functions you will need to implement:
1) createBinKeyFromKey(key) - return binKey. Write a function that converts your key (which is an integer) to binary format (as a string of 0s and 1s). The built-in Python function bin takes an integer parameter and converts it to a binary string starting with 0b followed by the binary conversion. For example, bin(9) returns 0b1001. Can you find a way to slice off the first two characters? (Hint: remember the slicing operator :.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
