| Shift Cipher Assignment Answers |
| Encryption |   |
Encode the following message using a shift 4 cipher, as Francis Bacon supposedly did. Note: You may use the encryption tool described here or you may do this by hand.
shift_encrypt('francis bacon',4)
'jvergmw fegsr'
Now encode it using a shift 15 cipher.
shift_encrypt('Francis Bacon',15)
'Fgpcrxh Bprdc'
>shift_encrypt('francis bacon',15)
'ugpcrxh qprdc'
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Decryption |   |
The following messages have been encoding using a shift cipher with key 8. Decode.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Cryptography |   |
The following message has been encoded using a shift cipher. What is the key?
Answer 13 The brute force method:
Cipher text: n puvyq funyy yrnq gurz
---------------------------
Shift: 0: n puvyq funyy yrnq gurz
Shift: 1: o qvwzr gvozz zsor hvsa
Shift: 2: p rwxas hwpaa atps iwtb
Shift: 3: q sxybt ixqbb buqt jxuc
Shift: 4: r tyzcu jyrcc cvru kyvd
Shift: 5: s uzadv kzsdd dwsv lzwe
Shift: 6: t vabew latee extw maxf
Shift: 7: u wbcfx mbuff fyux nbyg
Shift: 8: v xcdgy ncvgg gzvy oczh
Shift: 9: w ydehz odwhh hawz pdai
Shift: 10: x zefia pexii ibxa qebj
Shift: 11: y afgjb qfyjj jcyb rfck
Shift: 12: z bghkc rgzkk kdzc sgdl
Shift: 13: a child shall lead them
Shift: 14: b dijme tibmm mfbe uifn
Shift: 15: c ejknf ujcnn ngcf vjgo
Shift: 16: d fklog vkdoo ohdg wkhp
Shift: 17: e glmph wlepp pieh xliq
Shift: 18: f hmnqi xmfqq qjfi ymjr
Shift: 19: g inorj yngrr rkgj znks
Shift: 20: h jopsk zohss slhk aolt
Shift: 21: i kpqtl apitt tmil bpmu
Shift: 22: j lqrum bqjuu unjm cqnv
Shift: 23: k mrsvn crkvv vokn drow
Shift: 24: l nstwo dslww wplo espx
Shift: 25: m otuxp etmxx xqmp ftqy
Notice just a shifting the one-letter
word at the beginning helps, sinc ethere
arent that many 1-letter words in English:
Cipher text: n puvyq funyy yrnq gurz
---------------------------
Shift: 0: n
Shift: 1: o
Shift: 2: p
Shift: 3: q
Shift: 4: r
Shift: 5: s
Shift: 6: t
Shift: 7: u
Shift: 8: v
Shift: 9: w
Shift: 10: x
Shift: 11: y
Shift: 12: z
Shift: 13: a
Shift: 14: b
Shift: 15: c
Shift: 16: d
Shift: 17: e
Shift: 18: f
Shift: 19: g
Shift: 20: h
Shift: 21: i
Shift: 22: j
Shift: 23: k
Shift: 24: l
Shift: 25: m
Only 13 and 21 look like 1-letter words.
So we carry on with those:
Cipher text: n puvyq funyy yrnq gurz
---------------------------
Shift: 13: a child
Shift: 21: i kpqtl
And now 13 looks like the winner.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Affine encryption |
  |
>affine_encrypt('attack at dawn',3,2)
'chhcig ch lcqp'
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Affine decryption |   |
Decrypt the following message assuming it is an affine cipher with a slope of 3 and a shift of 2:
If (m,b) is the encryption key, then (m-1, - (m-1 * b)) is the decryption key. We need to find the inverse of 3. The multiplication table for 3 is:
So therefore the decryption key should be: (9, -(9*2)) = (9,-18) = (9,8)We encrypt using this decryption key to decode:
>affine_encrypt('goov wskb ixap kv',9,8)
'keep your chin up'
Thus for example:
'g' => 'k' (9,8) encoding 'g' = 6 6 * 9 = 2 mod 26 2 + 8 = 10 decoding 10 = 'k' Verifying:
>affine_encrypt('keep your chin up',3,2)
'goov wskb ixap kv'
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Finding Affine Keys |
  |
Determine the shift and slope for the following affine encryption scheme:
Compute encodings:
the simplest way to do this:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Valid Affine Keys |
  |
Suppose we change the ALPHABET we're encoding to include " "(space). That's one more character. That means we're now doing arithmetic mod 27 instead of mod 26. Previously (in mod 26) our valid slopes were all the odd numbers minus 13. What is our new set of valid slopes (in mod 27)? Valid slopes must be relatively prime to 27. The only factors of 27 are powers of 3. Therefore any multiple of 3 is excluded, leaving: 1 2 4 5 6 7 8 10 11 13 14 16 17 19 20 22 23 25 26 |