---
title: "Quiz: Cryptography Basics: Hashing, Encryption and Certificates"
domain: cybersecurity
level: beginner
questions: 10
---

# Quiz: Cryptography Basics: Hashing, Encryption and Certificates

## Questions

### 1. You compute the SHA-256 digest of a downloaded file and compare it with the published one. The two digests differ in just one hex character. What should you conclude?
*Objective: 1. Explain what a cryptographic hash guarantees and use one to check the integrity of a file.*

- A) The files are almost identical, so the difference is probably harmless corruption of a single bit.
- B) The files are not identical. Because of the avalanche effect, even a one-bit change gives a completely different digest, so a one-character difference is a mismatch to investigate.
- C) The two digests were computed with different hash algorithms, so you can't compare them.
- D) The file passed the check, because a hash only needs to match in most of its characters.

### 2. A team wants to verify files from an untrusted mirror using MD5 digests, "because they're fast and still catch changes." Why is this a poor choice?
*Objective: 1. Explain what a cryptographic hash guarantees and use one to check the integrity of a file.*

- A) MD5 is an encryption algorithm, so it hides the file but doesn't check it.
- B) MD5 digests are too short to notice that a file changed.
- C) MD5 can only be computed with a secret key that the mirror doesn't have.
- D) Practical collisions are known, so an attacker can craft a different file with the same MD5 digest.

### 3. After a breach, an analyst sees that the users `alice` and `carol` have exactly the same value in the `password_hash` column. Nothing else about the accounts is related. What does this most likely show?
*Objective: 2. Explain why passwords must be stored with a salt and a slow hash function, not with a plain hash or encryption.*

- A) The passwords were hashed without a unique salt, and both users most likely chose the same password.
- B) Alice and Carol are the same person using two accounts.
- C) A SHA-256 collision happened by chance.
- D) The database is corrupted, because hashes of different passwords are always different.

### 4. A developer proposes storing passwords encrypted with AES-256, keeping the key in an environment variable on the same server, "so support can send users their forgotten password." What is the best response?
*Objective: 2. Explain why passwords must be stored with a salt and a slow hash function, not with a plain hash or encryption.*

- A) Accept it, as long as the AES key is rotated every month.
- B) Accept it, as long as AES-GCM is used instead of AES-CBC.
- C) Reject it: encryption is reversible, so an attacker who reaches the server gets the key and every password. Store a salted, slow hash (for example Argon2id) and offer a password reset instead.
- D) Replace AES with a single round of SHA-256 over each password, which can't be reversed.

### 5. Two branch offices have never met and share no secret. They only have the public Internet, and they must send each other a 2 GB encrypted backup. Which approach is the best?
*Objective: 3. Compare symmetric encryption (AES) and asymmetric encryption (RSA, elliptic curves), and explain how protocols such as TLS combine them.*

- A) Email one office's AES key to the other, then encrypt the backup with it.
- B) Use asymmetric cryptography (a key exchange, with the public keys verified) to agree on a fresh symmetric key, then encrypt the backup with AES-GCM using that key.
- C) Encrypt the whole 2 GB file with RSA, because public-key cryptography is the strongest.
- D) Encode the file with Base64 and send it over HTTPS.

### 6. A tester changes a single byte in an AES-CBC ciphertext. The application decrypts it without any error and shows slightly altered data. Which change fixes the underlying problem?
*Objective: 3. Compare symmetric encryption (AES) and asymmetric encryption (RSA, elliptic curves), and explain how protocols such as TLS combine them.*

- A) Switch from a 128-bit to a 256-bit AES key.
- B) Store a SHA-256 hash of the ciphertext next to it in the same file.
- C) Switch to ECB mode, which doesn't chain blocks.
- D) Switch to an authenticated encryption mode such as AES-GCM, which detects any change and refuses to decrypt.

### 7. A software vendor wants customers worldwide to check that an update really comes from the vendor, and to be able to prove later that the vendor released it. The vendor doesn't want to share any secret with customers. Which tool fits?
*Objective: 4. Explain how a digital signature provides integrity and authenticity, and create and verify one.*

- A) A digital signature: the vendor signs with a private key it never shares, and customers verify with the published public key.
- B) An HMAC: the vendor sends every customer the secret key to compute the tag.
- C) A plain SHA-256 digest published next to the update on the vendor's website.
- D) AES encryption of the update with a password printed on the website.

### 8. You verify a signature with this command and get the output below. The file was modified after it was signed. What does the result tell you?
*Objective: 4. Explain how a digital signature provides integrity and authenticity, and create and verify one.*

```bash
openssl pkeyutl -verify -pubin -inkey public.pem -rawin -in message.txt -sigfile message.sig
```

```text
Signature Verification Failure
```

- A) The private key was used to verify, but it should be the public key.
- B) The signature is valid, but the file is too large to verify.
- C) The signature doesn't match this file and public key. The file or signature was changed, or the key is the wrong one, so you must not trust the file.
- D) The command only checks the signature format, not the file contents.

### 9. A user opens `https://shop.example.com` on 1 March 2026 and the browser shows a warning. The administrator runs the command below on the server's certificate. What is the most likely cause?
*Objective: 5. Read an X.509 certificate and explain how a certificate chain lets a browser trust a website.*

```bash
openssl x509 -in shop.crt -noout -subject -issuer -dates -ext subjectAltName
```

```text
subject=CN=shop.example.com
issuer=CN=Example Issuing CA
notBefore=Oct 12 08:00:00 2025 GMT
notAfter=Jan 10 08:00:00 2026 GMT
X509v3 Subject Alternative Name:
    DNS:shop.example.com
```

- A) The name in the address bar doesn't match the SAN.
- B) The certificate has expired: its `notAfter` date is before the date of the visit.
- C) The certificate is self-signed, because the subject and the issuer both contain `example.com`.
- D) The certificate uses a SAN instead of a Common Name, which browsers reject.

### 10. A web server sends its own certificate and one intermediate CA certificate, but not the root CA certificate. Browsers still validate the chain. Why?
*Objective: 5. Read an X.509 certificate and explain how a certificate chain lets a browser trust a website.*

- A) The root CA certificate is already in the browser's or operating system's root store, so the chain only has to end at it.
- B) The leaf certificate contains a copy of the root CA's private key.
- C) Browsers skip the verification of the last certificate in a chain.
- D) Any certificate that the server sends is trusted automatically.

---

## Answer key

<details>
<summary>Show answers</summary>

| # | Answer | Explanation |
|---|---|---|
| 1 | B | A good hash has the avalanche effect: any change, even one bit, changes about half the digest. Digests either match completely or the file is different. |
| 2 | D | MD5 is broken for collisions, so an attacker can make two different files with the same digest. A hash isn't encryption and needs no key, so A and C are wrong. |
| 3 | A | A unique random salt gives equal passwords different hashes. Identical values point to a missing (or shared) salt and the same password, so cracking one cracks both. |
| 4 | C | Encryption is reversible, and the key sits on the same server, so one breach exposes every password. Rotating the key or changing the mode (A, B) doesn't fix that, and a single plain SHA-256 round (D) is fast and unsalted. |
| 5 | B | Asymmetric cryptography solves key distribution but is slow, so it only agrees on a key; AES-GCM then protects the bulk data. This is the same pattern as TLS. Emailing the key (A) defeats the point, and Base64 (D) isn't encryption. |
| 6 | D | CBC has no integrity check, so changes aren't detected. An AEAD mode such as AES-GCM adds an authentication tag. A longer key (A) doesn't add integrity, a hash stored beside the ciphertext (B) can be replaced by the attacker, and ECB (C) is worse. |
| 7 | A | A signature needs no shared secret and gives integrity, authenticity and non-repudiation. An HMAC (B) shares the key, so it can't prove who created it, and a bare digest (C) can be replaced along with the file. |
| 8 | C | The signature doesn't match the file and key. You can't tell from the message alone whether the file, the signature or the key is wrong, so don't trust the file. Verification uses the public key (`-pubin`), as it should. |
| 9 | B | The SAN matches the name and the issuer differs from the subject, so it isn't self-signed. But `notAfter` is 10 January 2026, before the visit on 1 March 2026: the certificate has expired. Browsers use the SAN, so D is wrong. |
| 10 | A | Servers don't need to send the root, because the browser already has it in its root store and trusts it. The chain only has to end at a root in the store. |

</details>
