Module 3 · Cryptography and PKI · Lesson 23 of 42

Hashing, salting and digital signatures

One-way fingerprints for integrity, MD5, SHA and RIPEMD, protecting stored passwords, and proving who signed what.

In this lesson · about 28 minutes

  • Explain how hashing provides integrity, such as verifying a download
  • Explain what a hash is and why it can't be reversed
  • Compare MD5, SHA-1, SHA-2 and RIPEMD digest sizes and know which are broken
  • Explain salting and key stretching for stored passwords
  • Walk through how a digital signature is created and verified

Integrity: has this file changed?

Remember the CIA triad. Encryption handles confidentiality. Integrity asks a different question: is the file I downloaded, say an operating-system patch or a document, exactly what the publisher put on their server, or did someone change it along the way? You don't need encryption to answer that. You need a hash.

The publisher runs the file through a hash function and posts the result. You download the file, hash it yourself with any free hashing tool (for example sha256sum file.iso on Linux or Get-FileHash in Windows PowerShell), and compare. Same value: the file is intact. Different value: don't trust it.

What makes a hash useful

  • Fixed length: one letter or an entire encyclopedia produces a digest of the same size.
  • Avalanche effect: change a single character, even just a lowercase "i" to a capital "I", and the digest looks completely different.
  • One-way: you can't turn the digest back into the input.
  • Collision resistance: it should be practically impossible to find two different inputs with the same digest (a collision). Once attackers can create collisions, they can swap in a malicious file with a matching hash.

The output is called the message digest (or hash value, or fingerprint).

Hash algorithms for the exam

AlgorithmDigest sizeStatus
MD5 (Message Digest 5, Ron Rivest, early 1990s)128 bitsBroken: collisions are easy to create
SHA-1 (Secure Hash Algorithm, NIST/NSA)160 bitsBroken: practical collisions shown; retired
SHA-2 family: SHA-224, SHA-256, SHA-384, SHA-512Named by sizeCurrent standard: used across the web
SHA-3224–512 bitsNewer NIST standard with a different internal design
RIPEMD (RACE Integrity Primitives Evaluation Message Digest)128, 160, 256, 320 bitsOpen standard, rarely used; RIPEMD-160 is the common one

Where you'll meet hashes

  • Download and patch verification (above).
  • Password storage: systems store the hash of your password, not the password, so someone browsing the password database sees only digests. (Your password travels to the server protected by TLS; the server hashes it and compares.)
  • Digital signatures, HMACs and TLS: every HTTPS session uses hashes alongside symmetric and asymmetric encryption.

Try it: live hash calculator

See hashing in action

Two nearly identical phrases. Change a single letter and watch the digest change almost completely, while staying exactly the same length. Make the two inputs identical to see the digests match.

SHA-256: 256-bit digest (64 hex characters). SHA-2 family; today's everyday choice.

SHA-256 digest

SHA-256 digest

✗ The digests differ in 0 of 0 characters (highlighted), even though the inputs may look almost the same.

Hashing runs in your browser with the Web Crypto API; nothing is sent anywhere. Browsers don't offer MD5 because it's broken.

Hashing recap

A hash function turns input of any size into a fixed-size digest. It is one-way (you can't get the input back) and any tiny change gives a completely different digest. Hashes give integrity: if the digest matches, the data hasn't changed.

  • SHA-256 / SHA-3: current, strong choices.
  • MD5 and SHA-1: broken by collisions (two different inputs with the same hash). Don't use them for security.
  • HMAC: a hash combined with a secret key, proving both integrity and that the sender knew the key.

Protecting stored passwords

Systems store password hashes, not passwords. Attackers who steal hashes use precomputed rainbow tables or guess at high speed. Two defenses:

  • Salting: add a random value to each password before hashing. Identical passwords then have different hashes, and rainbow tables become useless.
  • Key stretching: hash many thousands of times (PBKDF2, bcrypt, Argon2) so every guess is slow.

Digital signatures

  1. The sender hashes the message.
  2. The sender encrypts that hash with their private key. That is the signature.
  3. The receiver decrypts the signature with the sender's public key and hashes the message themselves.
  4. If the two hashes match, the message is unchanged (integrity), really from the sender (authentication), and the sender can't deny it (non-repudiation).

A signature does not give confidentiality: the message itself can still be read unless it is also encrypted.

Performance-based question (PBQ)

Order the digital signature steps

A developer signs a software update and a customer's computer verifies it before installing. The steps below are shuffled.

Put each step in the correct position (1 is first).

  • The customer's computer decrypts the signature using the developer's public key
  • The developer hashes the update file
  • The computer compares the two hashes and installs only if they match
  • The developer encrypts the hash with their private key and attaches it
  • The computer hashes the update file it received
0 of 5 answered

Check your understanding0 of 9 correct

Question 1

1.Two users have the password 'Summer2025!' but their stored hashes are different. Why?

Question 2

2.Which is the BEST algorithm for storing passwords?

Question 3

3.Which does a digital signature NOT provide?

Question 4

4.Two different files produce the same MD5 hash. This is called…

Question 5

5.You download an ISO file and the vendor publishes its SHA-256 value. What does comparing the two values prove?

Question 6

6.What is the digest size of MD5?

Question 7

7.You hash a one-page memo and a 900-page manual with SHA-256. How do the digests compare in length?

Question 8

8.Which hash family is recommended for new systems today?

Question 9

9.Which algorithm comes in 128, 160, 256 and 320-bit versions?

Quiz score: 0 of 9

Tip: answer every quiz question correctly first.

Noviq Academy is free and for learning. This course is independent and is not affiliated with or endorsed by CompTIA. CompTIA and Security+ are trademarks of CompTIA, Inc. Exam details such as price and policies change; confirm them on CompTIA's website before you book.