Reviewed Aug 2026
DE
BA-02 · LESSON 02

Hash functions and SHA-256

KEY DEFINITIONS

Terms used in this lesson

SHA-256
A cryptographic hash function used throughout Bitcoin to produce fixed-size 256-bit digests.
Preimage
The original secret data whose hash equals a previously committed value.
ASCII
A standard mapping between common text characters and byte values.

A hash turns any message into a fixed-size fingerprint. Bitcoin commonly uses the Secure Hash Algorithm 256, called SHA-256, to detect changes and make commitments.

45 min Difficulty 1/5 Not started

Loading lesson visuals...

01

Learn the idea

A cryptographic hash function maps any byte string to a fixed-size digest. SHA-256 produces 256 bits, or 32 bytes. Preimage resistance makes it impractical to recover an input from a digest, collision resistance makes it impractical to find two inputs with the same digest, and the avalanche effect means a small input change usually changes many output bits.

GUIDED EXPLANATION1/5 ideas inspected
1

Serialize exact bytes

A hash receives bytes, not an abstract sentence or number. Encoding, length, and field order must be fixed before hashing.

Inspect each idea before the worked example.
The worked example follows the explanation

Inspect every idea above to open it.

Important distinctionSHA-256 encrypts data so only the intended recipient can read it.

Hashing is one-way and has no decryption key. Encryption is reversible for a key holder; hashing supports comparison and commitment.

02
FINISH LEARNING FIRST

The questions unlock after every required learning activity

Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.