Students can investigate the idea behind proof of work without installing a miner, opening a wallet or spending money. A short hashing activity lets them make predictions, test small changes and explain what their results do—and do not—demonstrate.
This lesson is a new teaching resource, not a claim about a historical EdTechTrain course. It is intended for a supervised computing lesson using a school-approved Python environment.
Choose a learning outcome that can be assessed
By the end, learners should distinguish a message from its encoded bytes, recognise a fixed-length hash output and explain why trying candidate inputs is different from decrypting a message. No cryptocurrency account, browser extension or third-party “mining simulator” is needed.
Ask students to predict whether changing one letter changes one character of the hash, many characters or its length. Have them write the prediction before running any code. That creates something concrete to revisit in the explanation rather than treating a long hexadecimal string as the lesson’s result.
Compare three deliberately small inputs
Python’s hashlib accepts bytes. Encoding text as UTF-8 makes that conversion explicit. The following example compares a word, a change of case and a trailing space:
import hashlib
for message in ["block", "Block", "block "]:
data = message.encode("utf-8")
digest = hashlib.sha256(data).hexdigest()
print(repr(message), len(data), digest)
Use repr so that the trailing space remains visible in the record. Learners should observe a 64-character hexadecimal output for each input and different values for the three examples. Repeating exactly the same bytes produces the same digest; it is not a new random draw on each run.
Ask a second pair to reproduce one result. If it differs, compare the literal input, spaces, capitalisation and encoding before changing the program. That is a useful introduction to reproducibility and to the difference between what a screen displays and what a computer actually processes.
Turn the hash into a bounded search
Now keep a message prefix fixed and try a small integer suffix until the hexadecimal digest starts with two zeroes. The upper limit is deliberate: every learner’s program terminates even if the chosen search range contains no match.
import hashlib
for candidate in range(20000):
data = f"classroom:{candidate}".encode("utf-8")
digest = hashlib.sha256(data).hexdigest()
if digest.startswith("00"):
print(candidate, digest)
break
else:
print("No match in the chosen search range")
Record how many candidates were tested, including the successful one. Starting at zero means that the successful candidate value alone is one less than the number of attempts. Compare that count with a different fixed prefix, rather than having every learner repeatedly run the identical deterministic search.
Discuss probability without promising a result
Two specified hexadecimal characters correspond to eight bits. In an idealised model, a candidate has a one-in-256 chance of satisfying this prefix condition. That does not mean every 256th candidate succeeds, nor does it guarantee that a particular finite range contains a match.
Different observed search lengths are therefore not automatically evidence that one computer is faster. The count of attempted candidates and the time per attempt are separate measurements. Keep the activity small; it is a concept demonstration, not a benchmark or an invitation to leave school devices computing unattended.
Explain where the Bitcoin analogy stops
This program hashes a short text once and checks a convenient visible prefix. Bitcoin proof of work operates on a structured block header using double SHA-256 and a numeric target. A toy match is not a valid Bitcoin block, does not submit work to a pool and earns nothing.
A hash is also not encryption. There is no decryption key that recovers the original message from this output. Avoid using real passwords or private student data as classroom inputs: a demonstration of hashing is not a demonstration of safe password storage.
Collect a small, useful piece of evidence
Ask each pair to submit one prediction, their exact input, the observed output and two sentences explaining the limits of the analogy. For a non-coding version, provide printed inputs and precomputed digests, then ask learners to match repeat inputs and identify hidden spaces.
Continue with the mining energy spreadsheet exercise to practise units and assumptions without predicting investment returns. The wider education technology resource collection covers choosing tools around the learning task.
Teacher references: Python hashlib and the Bitcoin mining developer guide.