liveBook · Manning

SHA-256

As explained in Real-World Cryptography

A member of the SHA-2 family of standardized cryptographic hash functions that produces a 256-bit digest.

SHA-256 is a standardized cryptographic hash function that turns any input—a file, message, or video—into a fixed 256-bit digest. The same input produces the same digest, while a tiny input change produces a dramatically different result. section 2.1 section 2.5.1

Its practical job is checking whether a downloaded file is the intended file. Hash the download, compare the result with the published SHA-256 digest, and treat a mismatch as a warning that the content differs. section 2.1

The useful properties are:

  • Determinism: identical input produces an identical digest. section 2.1
  • Fixed size: SHA-256 always produces 256 bits, regardless of input length. section 2.1
  • Second pre-image resistance: finding a different file with the same digest should be infeasible. section 2.1
  • Standardization: SHA-256 belongs to SHA-2, standardized by NIST in 2001. section 2.5.1

Verify a downloaded file

Run `openssl dgst -sha256 downloaded_file`, then compare the displayed digest with the value published on the download page. For example, the command may produce `f63e68ac0bf052ae923c03f5b12aedc6cca49874c1c9b0ccf3f39b662d1f487b`. section 2.1

$ openssl dgst -sha256 downloaded_file
f63e68ac0bf052ae923c03f5b12aedc6cca49874c1c9b0ccf3f39b662d1f487b

Use the command listing as a compact reference for computing a SHA-256 digest with OpenSSL. section 2.1

How Real-World Cryptography covers it

How deep it goes
Explains fixed-length hashing, security properties, and high-level SHA-2 construction, stopping short of implementation-level detail.
Examples
Uses download verification, OpenSSL commands, repeated inputs, changed inputs, and inputs of different lengths.
What it assumes
Assumes no cryptographic background for basic use, while explaining XOR before the high-level internal construction.
What you can do after
Apply it via OpenSSL to calculate a file digest and compare that digest against a published verification value.
How it connects
Links cryptographic hash functions with digests, second pre-image resistance, compression functions, and the Merkle–Damgård construction.

Also explained in

Compare how 4 books explain SHA-256 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Real-World Cryptography. The section links point to the parts of the book it draws on.