Skip to content
CryptoAcademy logo CryptoAcademy
Menu
Lesson Beginner · 10 min

What is hashing?

A hash is a one-way fingerprint of data. Same input, same fingerprint — change the data, even slightly, and the fingerprint changes beyond recognition.

In this lesson

  • Define a hash function in one sentence
  • Explain why hashing is one-way
  • Run a hash from the terminal and read the output

A fingerprint for data

A hash function takes an input of any size — a word, a photo, an entire blockchain — and returns a fixed-size string of bytes called a digest or hash. The same input always produces the same digest, every time, on every machine.

Think of it as a fingerprint: you can always compute it from the data, but you cannot rebuild the data from the fingerprint.

How a hash function works
A hash function turns input of any length into a fixed 256-bit digest INPUT — ANY SIZE Hello Blockchain 17 bytes SHA-256 one-way compression no key · deterministic · fast DIGEST — ALWAYS 256 BIT 7f83b1657ff1fc53b92dc1814 8a1d65dfc2d4b1fa3d677284 addd200126d9069 64 hexadecimal characters Change one character in the input and the entire digest changes. Going back from digest to input is computationally infeasible — hashing is one-way.
Any input, any size — always a 256-bit digest. Nothing travels back to the left.

Three properties make hashes useful everywhere in security:

Property What it means in practice
Deterministic The same input always yields the same digest — you can re-check anything later.
One-way Given a digest, recovering the input is computationally infeasible.
Avalanche effect A one-bit change in the input changes roughly half of the output bits.

Example · Checking a download

You download a 4 GB installer and the website publishes SHA-256: 9f2b…c41a. You hash the file locally, get the same digest, and know the download is byte-for-byte identical — no need to trust the connection.

The same trick protects git commits, package managers and firmware updates.

try it bash
echo -n "Hello Blockchain" | sha256sum\n# 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069  -

Hashing is not encryption

Encryption is reversible: you decrypt with a key. Hashing is one-way — there is no key and no way back. You cannot "decrypt" a hash; you can only compare it.

Hash playground

Type two sentences, hash them and compare. Then change a single character and watch the digest explode.

Try it yourself
Is a hash the same as a checksum?

A checksum is a hash used to detect accidental corruption. Cryptographic hashes additionally resist attackers who deliberately try to produce two inputs with the same digest.

Do hashes use a secret key?

Plain hashes (SHA-256) do not. If you need a key — say, to authenticate a message — you use HMAC, which is built on top of a hash function.

What if the input is huge?

Hash functions stream data in fixed-size blocks, so you can hash a 100 GB file with a few kilobytes of memory.

Check your understanding

Practice · server-graded
  • Which statement best describes a cryptographic hash function?

    1 pt

Properties of a hash

Practice · server-graded
  • Select every property of a cryptographic hash function.

    1 pt

Practice exercise

Practice: hash basics

Start exercise

Practice

  • Hash basics — practice Start

Share this page

Send this link to a friend, or scan the QR code to open it on your phone.