Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1for shift in range(1, 26): | AThe shift is not printed, so the attacker cannot tell which key produced the readable text. | |
| 2print(shift, decrypt(cipher, shift)) | BShows each shift next to its decrypted text so a person can spot which one reads as sensible | |
| 3A brute-force attack tries every possible Caesar shift, from 1 to 25 | Cfor shift in range(1, 26): | |
| 4The attacker picks the shift whose result reads as sensible text, such as real English words | DLoops through all 25 possible Caesar shifts so each one can be tried on the ciphertext | |
| 5for shift in range(1, 25): | Erange(1, 25) stops at 24, so shift 25 is never tried and the correct key could be missed. | |
| 6print(decrypt(cipher, shift)) | Fprint(shift, decrypt(cipher, shift)) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
brute-force attack — Trying every possible key, such as all 25 Caesar shifts, then choosing the result that reads as sensible text. A short key leaves few shifts to try, so the cipher is weak.for shift in range(1, 26):
print(shift)for shift in range(1, 26):
guess = decrypt(text, shift)
print(shift, guess)shifts = list(range(1, 26))
print(len(shifts))if "THE" in guess:
print(shift, guess)new = chr((ord(c) - 65 - shift) % 26 + 65)