A-level Computer Science revision · Exchanging data

Encryption and hashing

The idea

Symmetric encryption uses the same key to encrypt and decrypt, so the key must be shared securely. Asymmetric encryption uses a public key to encrypt and a private key to decrypt, so no secret key needs to be sent. Hashing turns data into a fixed-size value that cannot be reversed; it is used to store passwords and check integrity.

  1. Symmetric: one shared key, fast.
  2. Asymmetric: public and private key pair.
  3. Hashing: one-way; compare hashes to check passwords.

Watch out Hashing is not encryption: a hash cannot be decrypted.

See it worked

Worked example

Why are passwords stored as hashes?

  1. Hashes cannot be reversed.
  2. A stolen database holds no plaintext passwords (salting and slow hashes make guessing harder).
  3. Login compares the hash of the entered password.

Answer So a stolen database does not directly reveal the passwords

Your turn

Question 11 mark

In asymmetric encryption, which key does a sender use to encrypt a message for Bob?

Choose one
Question 21 mark

What is a weakness of symmetric encryption?

Choose one
Question 32 marks

Give one property of a good hashing function for passwords.

Write your answer, then see a model answer
  1. Name the property.
  2. Explain why it matters.

Answer It should always give the same output for the same input but be infeasible to reverse or to find two inputs with the same hash.

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms