Encryption key

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Encryption key

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does an encryption key do?
A It is the message that is being sent
B It is a value the algorithm uses to scramble and unscramble data
2. Which part of encryption needs to be kept secret?
A The key
B The algorithm
3. The same plaintext is encrypted with two different keys. What happens?
A The ciphertext is identical both times
B The ciphertext is different each time
4. Which key is harder to guess?
A A longer key
B A shorter key
5. An attacker knows the algorithm used but not the key. Can they easily read the data?
A No, they still need the key
B Yes, the algorithm alone is enough

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1key = 3 ASets the secret value the algorithm uses to scramble the data, here a Caesar shift of 3
2ciphertext = encrypt(plaintext, key) BThe algorithm can be public. Security depends on keeping the key secret, so knowing the algorithm alone does not let someone read the data.
3A different key gives different ciphertext, even with the same algorithm and plaintext Cencrypt("HI", 1) != encrypt("HI", 2)
4The same key is used to unscramble the ciphertext back into the plaintext DThe algorithm uses the key to scramble the plaintext into ciphertext
5A hacker who knows the algorithm can read the data without the key Eplaintext = decrypt(ciphertext, key)
6A shorter key is harder to guess than a longer key FA longer key has many more possible values, so it is harder to guess. A shorter key is easier to guess.

Definitions

encryption key

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
ciphertext ← encrypt(plaintext, ___)
2.
plaintext ← _______(ciphertext, key)
3.
IF ______(key) >= 128 THEN OUTPUT "Harder to guess" ENDIF
4.
// The algorithm can be public // The ___ must stay secret ciphertext ← encrypt(plaintext, key)
5.
c1 ← encrypt(plaintext, key1) c2 ← encrypt(plaintext, ____) OUTPUT c1 ≠ c2

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A key ← 3
B text ← "HELLO"
C cipher ← decrypt(text, key)
D OUTPUT cipher
Question 2
A key ← 5
B cipher ← "MJQQT"
C text ← decrypt(cipher, 7)
D OUTPUT text
Question 3
A c1 ← encrypt("CAT", 1)
B c2 ← encrypt("CAT", 1)
C IF c1 <> c2 THEN
D OUTPUT "Different"
E ENDIF
Question 4
A OUTPUT "Key: 7f3a9c"
B key ← "7f3a9c"
C cipher ← encrypt(text, key)
D OUTPUT cipher
Question 5
A IF len(keyA) < len(keyB) THEN
B OUTPUT "A is harder"
C ELSE
D OUTPUT "B is harder"
E ENDIF

Answer Key

Encryption key
Section A: Quick Questions
Q1
B — It is a value the algorithm uses to scramble and unscramble data
Q2
A — The key
Q3
B — The ciphertext is different each time
Q4
A — A longer key
Q5
A — No, they still need the key
Section B: Match the Pairs
Q1
key = 3 → Sets the secret value the algorithm uses to scramble the data, here a Caesar shift of 3
Q2
ciphertext = encrypt(plaintext, key) → The algorithm uses the key to scramble the plaintext into ciphertext
Q3
A different key gives different ciphertext, even with the same algorithm and plaintext → encrypt("HI", 1) != encrypt("HI", 2)
Q4
The same key is used to unscramble the ciphertext back into the plaintext → plaintext = decrypt(ciphertext, key)
Q5
A hacker who knows the algorithm can read the data without the key → The algorithm can be public. Security depends on keeping the key secret, so knowing the algorithm alone does not let someone read the data.
Q6
A shorter key is harder to guess than a longer key → A longer key has many more possible values, so it is harder to guess. A shorter key is easier to guess.
Section C: Definitions
Q1
encryption key — A secret value used by the encryption algorithm to scramble data into ciphertext and unscramble it again. A different key gives different ciphertext, and a longer key is harder to guess.
Section D: Fill in the Blanks
Q1
ciphertext ← encrypt(plaintext, key)
Q2
plaintext ← decrypt(ciphertext, key)
Q3
IF LENGTH(key) >= 128 THEN OUTPUT "Harder to guess" ENDIF
Q4
// The algorithm can be public // The key must stay secret ciphertext ← encrypt(plaintext, key)
Q5
c1 ← encrypt(plaintext, key1) c2 ← encrypt(plaintext, key2) OUTPUT c1 ≠ c2
Section E: Spot the Error
Q1
C — To scramble plaintext into ciphertext you call encrypt, not decrypt. Line 3 should be cipher ← encrypt(text, key).
Q2
C — The ciphertext was made with key 5, so it must be unscrambled with the same key. Using 7 gives the wrong text. It should be decrypt(cipher, key).
Q3
B — The program shows that a different key gives different ciphertext. Line 2 reuses key 1, which would give the same ciphertext as c1. It should use key 2.
Q4
A — The algorithm can be public, but the key must stay secret. Printing the key lets anyone decrypt the data. Line 1 should output the algorithm name, not the key.
Q5
A — A longer key is harder to guess. The condition must check that keyA is longer than keyB using >, otherwise the wrong key is reported as harder.