OCR H446 A Level Computer Science · 1.3 Exchanging Data
Stretch tasks Compression, Encryption and Hashing
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
Sort It
Sort each statement into the right box, like the tick box tables in the exam.
- 12 cards to sort into 3 boxes
- Drag a card, tap a box or press its number
- Combo points for cards sorted in a row
12 cards, about 4 minutes
Code Word
Guess the lesson's secret words. Every guess shows which letters are right.
- A clue for every word
- Tiles turn green, amber or grey after each guess
- Fewer guesses win more points
3 words, about 4 minutes
Link Up
12 tiles hide 3 groups of 4. Work out what links them.
- Pick four tiles that belong together
- Four slips and the round is over
- Fewer slips win more points
3 groups, about 3 minutes
Bug Hunt
Two statements are true and one has a bug. Catch the bug before it gets away.
- Three statements in every round
- Tap the one with the mistake
- Streaks win bonus points
5 rounds, about 4 minutes
Brain games
Train your brain on this lesson
Logic, memory and speed, built from this lesson's own key ideas. Win up to three diamonds in each game.
Odd One Out
Four tiles: three share a link and one does not. Spot the odd one out, then see what links the rest.
- Three belong together, one does not
- A hint shows the link, for fewer points
- Quick answers and streaks win more
8 rounds, about 3 minutes
Memory Flash
Study the term cards, then they flip over. Find the card that goes with each clue, from memory.
- Three levels: 3, 4 and 6 cards
- Two tries to find each card
- Streaks win bonus points
3 levels, about 4 minutes
Fact or Fib
Statements fly in one at a time. Is each one a fact or a fib? Decide fast.
- Swipe, tap or use the arrow keys
- Every fib comes with its fix
- Streaks multiply your points
12 statements, about 3 minutes
The final challenge
City Run
Race a robot cat on inline skates through a neon cyber city, from Neon Station to the Hyper Tunnel. Every question is a row of neon gates across the tracks: skate through the one with the right answer, dodge the trains and barriers, and grab diamonds.
- 20 questions from this lesson, in four parts of the city
- Swipe, tap or use the arrow keys
- Dodge trains and holograms, and jump crates and cones
20 questions, about 6 minutes
Bonus challenge
Neon Roll
Roll a glowing ball down an endless neon slope, past towers lit up with neon signs of Pixel the cat. Steer, jump the gaps and dodge the blocks. Questions from this lesson wait at gates along the way: every right answer keeps the ball rolling.
- Questions from this lesson at every gate
- Hold the arrow keys or a side of the slope to steer
- 8 right answers win two diamonds, 15 win three
Endless, about 5 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Compression, Encryption and Hashing
Compression, Encryption and Hashing: the questions
Quiz Challenge, round 1: Quiz Blitz
What is AAAAABBBCCCCCCCC after run length encoding?
- 5A 3B 8C
- 5A 3B 7C
- A B C
- 16 ABC
Which data would run length encoding compress worst?
- An icon with large blocks of one colour
- A long line of identical pixels
- A scan of a mostly white page
- Text with almost no repeated neighbouring characters
Lossless compression lets the original file be restored exactly.
- True
- False
Which kind of compression is the basis of ZIP files?
- Lossy compression
- Run length encoding only
- Hashing
- Dictionary encoding
What is the key distribution problem?
- Storing too many public keys
- Keys being too long to type
- Losing a private key
- Getting a symmetric key to the recipient without it being intercepted
Which THREE are properties of a good hash function?
Tick 3.
- Avalanche effect
- Reversible with a key
- Output grows with the input
- Deterministic
- One way
Put the steps of signing and checking a message in order.
Number these 1 to 4.
- The hash is encrypted with the sender's private key
- The recipient decrypts the signature with the sender's public key
- The recipient compares it with a fresh hash of the message
- The sender hashes the message
A stored password hash can be decrypted to recover the password.
- True
- False
What is the name for a random value added to a password before it is hashed?
In HTTPS, what is asymmetric encryption used for?
- Encrypting every packet of the page
- Compressing the page
- Hashing the passwords
- Exchanging a symmetric session key securely
What does a digital certificate do?
- Stores a hash of the website
- Compresses a key so it is quicker to send
- Binds a public key to a verified identity
- Encrypts a message with a private key
Which key do you use to send someone a message that only they can read?
- Their public key
- Their private key
- Your public key
- Your private key
Quiz Challenge, round 2: Quick Fire
Explain why run length encoding can make some files larger. [2 marks]
Explain the key distribution problem in symmetric encryption. [2 marks]
Explain why passwords should be salted before they are hashed. [2 marks]
Explain how a hash can show that a downloaded file has not been changed. [2 marks]
Quiz Challenge, round 3: Big Think
Compare symmetric and asymmetric encryption, and explain how HTTPS uses both. [6 marks]
Describe how a digital signature proves who sent a message and that it has not been changed. [4 marks]
This or That: tick the right answer
Which suits a large photo on a web page that must load quickly?
- Lossless
- Lossy
Which suits compressing a program file?
- Lossless
- Lossy
Which encoding suits text full of repeated words?
- Dictionary encoding
- Run length encoding
Which key decrypts a message sent to you with your public key?
- Your private key
- Your public key
Which is one way by design?
- Encryption
- Hashing
What does a tiny change to the input do to a good hash?
- Changes it completely
- Changes one character
Which is faster for encrypting large amounts of data?
- Symmetric
- Asymmetric
What makes two users with the same password store different hashes?
- A salt
- A longer hash
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Run length encoding | 1 Tiny input change, completely different hash |
| B Dictionary encoding | 2 Symmetric key agreed at the start of HTTPS |
| C Salt | 3 Binds a public key to a verified identity |
| D Digital certificate | 4 Replaces a run of one value with a count |
| E Avalanche effect | 5 Random value added to a password before hashing |
| F Session key | 6 Replaces repeated sequences with references |
Sort It: tick one box in each row
Is each statement about symmetric encryption, asymmetric encryption or hashing?
| Statement | Symmetric | Asymmetric | Hashing |
|---|---|---|---|
| Used for the data once an HTTPS session starts | |||
| Produces a fixed size output from any input | |||
| Solves the key distribution problem | |||
| Lets anyone send you a message only you can read | |||
| The key must be sent to the recipient securely | |||
| One key both encrypts and decrypts | |||
| Fast enough for large amounts of data | |||
| Cannot be reversed to recover the input | |||
| A tiny change to the input changes the output completely | |||
| Much slower, so it is used sparingly | |||
| Uses a public key and a private key | |||
| Used to store passwords safely |
Code Word: write the word that fits each clue
Compression that throws away data you are unlikely to notice. (5 letters)
A random value added to a password before it is hashed. (4 letters)
The key in a pair that is never shared. (7 letters)
Link Up: find the three groups
These 12 tiles make 3 groups of 4. Write each group in the table, and what links its tiles.
- Key pair
- Private key
- Public key
- Collision resistant
- PNG
- Avalanche effect
- Dictionary encoding
- One way
- Digital signature
- Run length encoding
- ZIP
- Deterministic
| Group | The 4 tiles | What links them |
|---|---|---|
| Group 1 | ||
| Group 2 | ||
| Group 3 |
Bug Hunt: tick the statement that is wrong
In each set, two statements are true and one has a mistake in it.
- Run length encoding always makes a file smaller.
- Dictionary encoding stores its dictionary with the data.
- Run length encoding stores a count beside each value.
- Lossless compression can restore the original exactly.
- Lossy compression is the right choice for program files.
- Lossy compression suits photos, audio and video.
- Symmetric encryption uses the same key to encrypt and decrypt.
- Asymmetric encryption solves the key distribution problem.
- Asymmetric encryption is faster than symmetric encryption.
- A certificate authority issues digital certificates.
- A digital signature is a hash encrypted with a private key.
- A digital signature is checked with the sender's private key.
- A good hash function always gives the same output for the same input.
- A hash can be reversed with the right key.
- A salt makes identical passwords hash differently.
Brain game: Odd One Out
Three tiles in each set share a link. Tick the odd one out, then write what links the other three.
- PNG
- Dictionary encoding
- One way
- ZIP
What links the other three?
- Collision resistant
- Avalanche effect
- One way
- Digital signature
What links the other three?
- Key pair
- Public key
- One way
- Digital signature
What links the other three?
- Public key
- PNG
- Dictionary encoding
- Run length encoding
What links the other three?
- Key pair
- Private key
- Public key
- PNG
What links the other three?
- PNG
- Dictionary encoding
- Digital signature
- ZIP
What links the other three?
Brain game: Memory Flash, on paper
Which term means this? Write your answer from memory.
Replaces a run of one value with a count
Random value added to a password before hashing
Replaces repeated sequences with references
Tiny input change, completely different hash
Symmetric key agreed at the start of HTTPS
Binds a public key to a verified identity
Brain game: Fact or Fib
Tick Fact if the statement is true and Fib if it is not.
Lossy compression is the right choice for program files.
- Fact
- Fib
A stored password hash can be decrypted to recover the password.
- Fact
- Fib
Run length encoding always makes a file smaller.
- Fact
- Fib
A certificate authority issues digital certificates.
- Fact
- Fib
Lossless compression can restore the original exactly.
- Fact
- Fib
A good hash function always gives the same output for the same input.
- Fact
- Fib
Lossy compression suits photos, audio and video.
- Fact
- Fib
A digital signature is checked with the sender's private key.
- Fact
- Fib
A hash can be reversed with the right key.
- Fact
- Fib
Asymmetric encryption solves the key distribution problem.
- Fact
- Fib
Symmetric encryption uses the same key to encrypt and decrypt.
- Fact
- Fib
Asymmetric encryption is faster than symmetric encryption.
- Fact
- Fib
City Run
City Run is a race through a neon cyber city, played on screen. It asks 20 of the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Neon Roll
Neon Roll is a ball rolling down an endless neon slope, played on screen. Every right answer keeps it rolling. It asks the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Answers
Round 1: Quiz Blitz
- 5A 3B 8C Each run becomes a count and the value: five As, three Bs and eight Cs.
- Text with almost no repeated neighbouring characters With few runs, every single value needs a count beside it, so the file can grow.
- True Lossless encodes the data more efficiently but throws nothing away, which is essential for text and program files.
- Dictionary encoding ZIP replaces repeated sequences with references to a dictionary, and it is lossless.
- Getting a symmetric key to the recipient without it being intercepted With one shared key, anyone who intercepts it can read everything. Asymmetric encryption removes the need to send it.
- Deterministic; One way; Avalanche effect The same input always gives the same hash, it cannot be reversed, and a tiny change transforms the output. The output is always a fixed size.
- The sender hashes the message → The hash is encrypted with the sender's private key → The recipient decrypts the signature with the sender's public key → The recipient compares it with a fresh hash of the message Hash, encrypt the hash with the private key, decrypt it with the public key, then compare it with a new hash. A match proves who sent it and that it is unchanged.
- False Hashing is one way. To check a password, the system hashes what was typed and compares the two hashes.
- salt A salt makes identical passwords hash differently and defeats precomputed rainbow tables.
- Exchanging a symmetric session key securely Asymmetric encryption sets up the session key, then fast symmetric encryption carries the data.
- Binds a public key to a verified identity Issued by a certificate authority, it stops an attacker simply publishing a public key that claims to be your bank.
- Their public key Anything encrypted with their public key can only be decrypted with their private key, which only they hold.
Round 2: Quick Fire
- The data has few runs of identical values
- So each single value still needs a count stored beside it
Model answerIf the data has few runs of identical values, each single value still needs a count stored beside it, so the encoded file can be larger than the original.
- The same key encrypts and decrypts, so it must be shared with the recipient
- If it is intercepted, an attacker can decrypt everything
Model answerThe same key is used to encrypt and decrypt, so it has to be sent to the recipient. If it is intercepted on the way, an attacker can decrypt every message.
- Identical passwords then produce different hashes
- Precomputed rainbow tables become useless
Model answerA random salt is added to each password, so two people with the same password get different hashes, and attackers cannot use precomputed rainbow tables to look the hashes up.
- Hash the downloaded file again
- Compare it with the published hash: a match means it is unchanged
Model answerHash the downloaded file again and compare the result with the hash published by the source. If the two match, the file has not been altered.
Round 3: Big Think
- Symmetric encryption uses the same key to encrypt and decrypt
- Symmetric encryption is fast
- The symmetric key must be distributed securely, the key distribution problem
- Asymmetric encryption uses a public key and a private key
- Asymmetric encryption is much slower
- HTTPS uses asymmetric encryption to exchange a symmetric session key
- Then the data itself is encrypted symmetrically, for speed
Model answerSymmetric encryption uses the same key to encrypt and decrypt, which is fast, but the key has to be sent to the recipient, and if it is intercepted the encryption is worthless, the key distribution problem. Asymmetric encryption uses a key pair: a public key that anyone can have and a private key that is never shared, which solves key distribution but is much slower. HTTPS uses asymmetric encryption at the start of the connection to exchange a symmetric session key securely, then all the data is encrypted symmetrically because it is far faster.
- The sender hashes the message
- The hash is encrypted with the sender's private key
- The recipient decrypts it with the sender's public key
- The recipient hashes the message and compares the two hashes
- A match shows it is unaltered and came from the holder of the private key
Model answerThe sender makes a hash of the message and encrypts the hash with their private key, which is the signature. The recipient decrypts it with the sender's public key and hashes the message they received. If the two hashes match, the message is unaltered and must have come from the holder of the private key.
This or That
- Lossy Lossy discards detail the eye barely notices, giving much smaller files. Lossless keeps every byte, so the file stays large.
- Lossless Every byte of a program matters, so it must be restored exactly.
- Dictionary encoding Repeated words are rarely next to each other, so they form no runs. A dictionary replaces each with a short reference.
- Your private key The keys are a pair: what one key locks, only the other unlocks. Your private key never leaves you.
- Hashing Encryption can be reversed with the right key. A hash cannot be reversed at all.
- Changes it completely That is the avalanche effect, which stops anyone learning about the input from similar hashes.
- Symmetric Symmetric encryption is far faster, which is why HTTPS switches to it once the session key is agreed.
- A salt A random salt is added to each password before hashing, so identical passwords give different hashes.
Memory Match
- A 4 Run length encoding: Replaces a run of one value with a count
- B 6 Dictionary encoding: Replaces repeated sequences with references
- C 5 Salt: Random value added to a password before hashing
- D 3 Digital certificate: Binds a public key to a verified identity
- E 1 Avalanche effect: Tiny input change, completely different hash
- F 2 Session key: Symmetric key agreed at the start of HTTPS
Sort It
- Symmetric Used for the data once an HTTPS session starts After the session key is agreed, HTTPS carries the data with fast symmetric encryption.
- Hashing Produces a fixed size output from any input A hash is always the same size, however large the input.
- Asymmetric Solves the key distribution problem The public key can be shared openly, so no secret key ever has to be sent.
- Asymmetric Lets anyone send you a message only you can read Anyone can encrypt with your public key, but only your private key decrypts.
- Symmetric The key must be sent to the recipient securely That is the key distribution problem, the weakness of symmetric encryption.
- Symmetric One key both encrypts and decrypts Using the same key both ways is what makes encryption symmetric.
- Symmetric Fast enough for large amounts of data Symmetric encryption is far faster than asymmetric.
- Hashing Cannot be reversed to recover the input Hashing is one way by design.
- Hashing A tiny change to the input changes the output completely That is the avalanche effect of a good hash function.
- Asymmetric Much slower, so it is used sparingly Asymmetric encryption is slow, so HTTPS uses it only to agree a session key.
- Asymmetric Uses a public key and a private key A mathematically linked key pair is what makes encryption asymmetric.
- Hashing Used to store passwords safely Systems store a salted hash, never the password itself.
Code Word
- LOSSY Compression that throws away data you are unlikely to notice.
- SALT A random value added to a password before it is hashed.
- PRIVATE The key in a pair that is never shared.
Link Up
- Lossless methods Run length encoding; Dictionary encoding; ZIP; PNG
- Properties of a good hash Deterministic; One way; Avalanche effect; Collision resistant
- Asymmetric encryption Public key; Private key; Digital signature; Key pair
Bug Hunt: the wrong statement, and why
- Run length encoding always makes a file smaller. With few runs, each single value still needs a count, so the file can grow.
- Lossy compression is the right choice for program files. Every byte of a program matters, so it needs lossless compression. Lossy suits media, where some loss goes unnoticed.
- Asymmetric encryption is faster than symmetric encryption. Asymmetric encryption is much slower. That is why HTTPS uses it only to agree a symmetric session key.
- A digital signature is checked with the sender's private key. The recipient checks it with the sender's public key. The private key never leaves the sender.
- A hash can be reversed with the right key. Hashing is one way. You never decrypt a hash: you hash the new input and compare.
Odd One Out
- One way is the odd one out: it goes with Properties of a good hash. The other three: Lossless methods.
- Digital signature is the odd one out: it goes with Asymmetric encryption. The other three: Properties of a good hash.
- One way is the odd one out: it goes with Properties of a good hash. The other three: Asymmetric encryption.
- Public key is the odd one out: it goes with Asymmetric encryption. The other three: Lossless methods.
- PNG is the odd one out: it goes with Lossless methods. The other three: Asymmetric encryption.
- Digital signature is the odd one out: it goes with Asymmetric encryption. The other three: Lossless methods.
Memory Flash
- Run length encoding Replaces a run of one value with a count
- Salt Random value added to a password before hashing
- Dictionary encoding Replaces repeated sequences with references
- Avalanche effect Tiny input change, completely different hash
- Session key Symmetric key agreed at the start of HTTPS
- Digital certificate Binds a public key to a verified identity
Fact or Fib
- Fib Lossy compression is the right choice for program files. The fix: Every byte of a program matters, so it needs lossless compression. Lossy suits media, where some loss goes unnoticed.
- Fib A stored password hash can be decrypted to recover the password. The fix: Hashing is one way. To check a password, the system hashes what was typed and compares the two hashes.
- Fib Run length encoding always makes a file smaller. The fix: With few runs, each single value still needs a count, so the file can grow.
- Fact A certificate authority issues digital certificates.
- Fact Lossless compression can restore the original exactly.
- Fact A good hash function always gives the same output for the same input.
- Fact Lossy compression suits photos, audio and video.
- Fib A digital signature is checked with the sender's private key. The fix: The recipient checks it with the sender's public key. The private key never leaves the sender.
- Fib A hash can be reversed with the right key. The fix: Hashing is one way. You never decrypt a hash: you hash the new input and compare.
- Fact Asymmetric encryption solves the key distribution problem.
- Fact Symmetric encryption uses the same key to encrypt and decrypt.
- Fib Asymmetric encryption is faster than symmetric encryption. The fix: Asymmetric encryption is much slower. That is why HTTPS uses it only to agree a symmetric session key.

