Module 6 · Cryptography and PKI · Lesson 17 of 75

Hashing, password storage and digital signatures

What makes a good hash, how passwords should be stored (salts and slow hashes), how attackers crack them, HMACs, and how digital signatures prove who signed what.

In this lesson · about 40 minutes

  • List the properties of a secure hash and the algorithms to avoid
  • Explain salting and slow password hashes, and how cracking works
  • Describe how a digital signature is made and verified

Properties of a secure hash

  • Fixed length: SHA-256 always gives 64 hex characters, for one letter or a 10 GB file.
  • One-way: you cannot work back from the hash to the input.
  • Avalanche effect: change one bit of input and about half the output bits flip.
  • Collision resistant: it is infeasible to find two inputs with the same hash.

MD5 and SHA-1 have practical collisions and must not be used for security (MD5 is still fine as a quick "did this download corrupt?" check). Use SHA-256, SHA-3 or BLAKE2/3.

Try it: live hash calculator

See the avalanche effect

Change a single character in one box and compare the two fingerprints.

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.

Storing passwords

Systems should never store passwords, only hashes of them. When you log in, the system hashes what you typed and compares. But fast hashes like SHA-256 are a poor fit for passwords: a graphics card can try billions per second. Good password storage adds two things:

  • A salt: a random value stored with each hash, so two users with the same password get different hashes, and precomputed rainbow tables become useless.
  • A slow, memory-hard algorithm designed for passwords: Argon2id, bcrypt, scrypt or PBKDF2 with many iterations ("key stretching"). One login is unnoticeably slower; billions of guesses become impractical.

In /etc/shadow you will see formats like $6$salt$hash (SHA-512-crypt) or $y$... (yescrypt). On Windows, local passwords are stored as NT hashes (unsalted), which is why they are such a valuable target (Module 21).

How cracking works

Attackers who steal a hash database guess offline with tools such as Hashcat and John the Ripper: dictionary attacks with leaked-password lists (like the famous rockyou list), rules that add common twists (Summer2026!), masks for known patterns, and brute force for short passwords. Length beats complexity: a four-word passphrase is far stronger than P@ss1!.

Try it: password cracking lab

Lab: crack a (fake) password file

Attack a stolen file of made-up hashes with brute force, a dictionary and a precomputed table. Then switch salting on and watch which attacks stop working, and use the estimator to see what key stretching does to the attacker's time.

Stolen password file (SHA-256)

userstored hashcracked

Everything runs in your browser on made-up accounts. A real rainbow table uses hash chains and reduction functions to store far less than this simple lookup table, but the idea is the same: the work is done before the attack.

How long would brute force take?

9 characters from a pool of 95 possible characters = about 10^17 combinations.

Fast hash, no stretching

Average brute-force time: about 365 days

Key stretching (PBKDF2, 600,000 rounds)

Average brute-force time: about 599,142 years

✗ This is a common word with a few characters on the end. A dictionary attack tries it in the first few hundred guesses, so the brute-force times above don't protect it.

Assumes an attacker testing 10 billion guesses per second against a fast hash such as unsalted SHA-256. Real rates depend on the hardware and the hash, so treat these as rough comparisons.

HMAC

A hash anyone can recompute does not prove who made it. An HMAC mixes a secret key into the hash, so only someone with the key can produce a valid one. Web APIs and webhooks use HMACs to prove a message came from the real sender and was not changed.

Digital signatures

  1. The sender hashes the document.
  2. They sign the hash with their private key. That signed hash is the signature.
  3. The receiver hashes the document themselves and verifies the signature with the sender's public key.
  4. If the two match, the document is unchanged (integrity), it came from the key holder (authenticity), and the signer cannot later deny it (non-repudiation).

Signatures protect software updates, code, emails (S/MIME, DKIM), documents and every TLS certificate.

Check your understanding0 of 4 correct

Question 1

1.What does a salt defeat?

Question 2

2.Which algorithm is designed for storing passwords?

Question 3

3.To sign a document, the sender uses...

Question 4

4.Which hash should no longer be used for security?

Quiz score: 0 of 4

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.