Example 1: Software Download Verification
A Linux distribution publishes ISO images for download. On their download page, alongside each ISO they publish its SHA-256 hash: a3b4c5...e9f0
After downloading the 4 GB ISO, you run: sha256sum ubuntu-22.04.iso
If the output matches the published hash exactly β bit for bit β the file is authentic and complete. If even a single byte was corrupted during download, or if the CDN served a tampered file, the hash will be completely different.
Example 2: Password Database Breach β Salted vs. Unsalted
A social media site with 50 million users suffers a database breach. The attacker steals the password table.
Unsalted scenario: The password table has: UserID | PasswordHash. The attacker runs the stolen hashes through a rainbow table lookup. "abc123" always produces hash e99a18c.... Within hours, 30% of accounts are cracked. The 5 million users who all used "password1" are all identified simultaneously β one lookup reveals them all.
Salted scenario: The password table has: UserID | Salt | SaltedHash. Each user has a unique 16-byte salt. Rainbow tables are useless β each user requires their own brute-force attack. The attacker can crack accounts, but must work them individually. Users with strong passwords (long, complex, unique) are effectively immune to offline cracking even with unlimited time.
Example 3: Code Signing β Verifying a Windows Driver
A hardware manufacturer publishes a device driver. They sign it with their code-signing certificate (their private key creates a signature over the driver's hash).
When Windows installs the driver:
- Windows computes the SHA-256 hash of the driver file.
- Windows finds the manufacturer's digital signature embedded in the file.
- Windows decrypts the signature using the manufacturer's public key (from their certificate, which chains to a trusted CA).
- Windows compares the decrypted hash to the computed hash.
- Match β driver is authentic and unmodified β installation proceeds.
- Mismatch β Windows shows a warning and may block installation.
If malware modifies the driver file (to add a backdoor), the hash changes. The signature no longer matches. Windows detects the tamper. The malware cannot create a valid signature without the manufacturer's private key, which they don't have.
Example 4: File Integrity Monitoring on a Web Server
A security team deploys a File Integrity Monitor (FIM) on their web servers. During initial setup, the FIM hashes every file in the web root, configuration directories, and system binary locations. These hashes become the baseline.
Every 15 minutes, the FIM recomputes hashes of all monitored files and compares to baseline. If a file's hash changes, an alert fires immediately.
Three weeks later, an attacker exploits a vulnerability and modifies index.php to add a web shell. The FIM detects the hash change within 15 minutes, alerts the security team, and the compromise is contained before significant damage occurs.
Without FIM, the modified file might have gone undetected for weeks while the attacker operated the web shell.
Example 5: Email Digital Signature (S/MIME)
A CFO sends an email approving a $500,000 wire transfer. The email is digitally signed using S/MIME.
The CFO's email client: hashes the email body β encrypts the hash with the CFO's private key β attaches the signature to the email.
The recipient's email client: decrypts the signature with the CFO's public key (from their S/MIME certificate) β hashes the received email body β compares the two hashes.
Match: the email was sent by the CFO (only they have that private key) and has not been modified in transit.
Later, if the CFO claims they never sent the approval, the signed email is mathematical proof. Non-repudiation: the private key is theirs alone β only they could have produced that signature.
Exam Scenario 1
Question: A database of user passwords is stolen. The passwords were stored as SHA-256 hashes without salts. What attack is the database most vulnerable to?
Answer: Rainbow table attack. Without salts, every instance of the same password has the same hash. An attacker can use precomputed rainbow tables to look up hashes and instantly identify the original passwords. Salting would have defeated this β each user's unique salt means the attacker must brute-force each account individually.
Exam Scenario 2
Question: Which cryptographic operation does a sender perform to create a digital signature?
Answer: Hash the document, then encrypt the hash with the sender's own private key. Note the direction: for encryption (confidentiality), you encrypt with the RECIPIENT's public key. For digital signatures (authentication/integrity), you encrypt the hash with YOUR OWN private key. Anyone can verify by decrypting with your public key β but only you could have created the signature.