AFFINE SHIFT CIPHERS
In Section 8.2, you learned about modular arithmetic. In this project, you will use modular arithmetic to encode and decode messages.
One method of encoding messages is to simply convert the letters of the alphabet to numbers by identifying A with , B with , and so on.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
A message encoded in this manner would be a string of numbers. We can make this encryption slightly more advanced by using a shift cipher, also called a Caesar cipher, which converts the message back to a string of letters. To use a shift cipher on the numerically encoded alphabet, add a fixed value (the "shift" value) to the number and then calculate the result modulo , then substitute the corresponding value into the encoded string.
For example, suppose we want to encode the letter T using a shift cipher with a shift of . First, we need to know that T corresponds to . Adding the shift value results in a value of , which is not a number modulo . We can calculate that . The letter we'd use in the encoded message is C.
-
Encode the word NOTE using a shift cipher with a shift value of .
If the value of the shift is known, a shift cipher is easy for anyone to decode. In the example with a shift of , the encoded letter was C, which corresponds to a value of . To decode this letter, we subtract the shift value to get . Since this number is negative, we can add to get a value between and . In this case, we get , which corresponds to T.
-
Decode DLQP that was coded using a shift cipher with a shift of .
Since shift ciphers are relatively easy to decode, more advanced coding methods are used to keep information safe. One slightly more advanced method is an affine shift cipher. This method involves multiplying the letter value by a number relatively prime to , called the key, before adding the shift value. For example, suppose we want to encode the letter T using an affine shift cipher with a key of and a shift of . We would compute . Next, we would calculate . This means the encoded letter is M.
-
Encode the word CODE using an affine shift cipher with a key of and a shift of .
To decode a message encoded with a shift cipher, the shift value is subtracted. To decode a message encoded with an affine shift cipher, the shift value is first subtracted and then division modulo is performed. Division in modular arithmetic is a little tricky; it involves multiplying by the multiplicative inverse of the key modulo . For example, if the value of the key is k, we need to find a value d so that . This is the reason we want k to be relatively prime to is the multiplicative inverse of k modulo .
-
List out the numbers less than that are relatively prime to .
-
Suppose you intercept a message and discover that it is encoded using an affine shift cipher with a key of and a shift of . Determine the multiplicative inverse of the key modulo . (Hint: Use the list created in part 4 and determine the value of each product modulo .)
-
You intercept a message that you know has been encoded with an affine shift cipher that has a key of and a shift of . Decode the following message.
OCO MOOKORMZSY LYIUKLYV
-
You are told that the following responses to such messages are common.
-
SENDING
-
DECLINE
-
UNCLEAR
Choose a response to the message and encode it using the same cypher.
-