liveBook · Manning

Cryptographic hash

As explained in Fundamentals of Cybersecurity

A cryptographic hash function is an algorithm that maps arbitrary-length input to a fixed-length digest while providing properties such as one-wayness and collision resistance.

A cryptographic hash function turns input of any size into a fixed-length value called a hash or message digest. Hashing is one-way: the original data cannot be recovered from the digest, and no key is used. section 14.2.4

A hash helps check integrity, not confidentiality. If data changes, its newly calculated hash will differ. Encryption can protect data’s confidentiality while hashing helps check whether it was altered. section 14.2.4

Checking a file

A website provides a SHA-256 checksum with a download. After downloading the file, calculate its hash with a hashing tool and compare it with the published value. A match indicates the file was not altered or corrupted during transmission. section 14.2.4

Hash comparisons can help check integrity in several settings:

  • Messages: the recipient hashes the received message and compares the result with the supplied digest. section 14.2.4
  • Database records and logs: a changed record or log can produce a hash that no longer matches, alerting analysts to possible tampering. section 12.6.3 section 14.2.4

Hash algorithms differ. MD5 is a legacy option and is not recommended for security; SHA-1 is deprecated because of collision attacks. SHA-2 includes SHA-256 and SHA-512, while SHA-3 is described as an alternative to SHA-2. section 14.2.4

Figure 14.3 Illustration of Alice sending a message to Bob using hashing to ensure integrity

Illustrates a sender sharing a message digest so a recipient can check the message’s integrity. section 14.2.4

How Fundamentals of Cybersecurity covers it

How deep it goes
Defines fixed-length digests and one-way hashing, explains verification, and compares algorithms without detailing their internals.
Examples
Uses an Alice-to-Bob message, a downloaded file with a SHA-256 checksum, and database records or logs.
What you can do after
Apply a hashing tool to compare a downloaded file’s digest with its published checksum and detect changes.
How it connects
Connects hashing with encryption, digital signatures, and data integrity.

Also explained in

Compare how 6 books explain cryptographic hash →

Related concepts

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