One-way functions
A calculation that is easy to do forwards but practically impossible to reverse, like mixing paint. It is the idea behind hashing and public-key encryption.
Understanding One-way functions in ACARA Digital Technologies Years 9–10
What it does: The mix() call is the easy forward step. The paint analogy shows that going backwards from green to the original colours is practically impossible. This easy forward, hard backward gap is what RSA public-key encryption relies on. Hashing is one-way, so the stored hash does not reveal the password. The site hashes what you type and compares the two hashes. Caesar and rail fence ciphers are easily reversed with the key. Hashing and public-key encryption rely on one-way ideas. You cannot easily unmix purple into the exact original red and blue. This is the paint idea behind one-way functions.
Common mistakes: The one-way function here is multiplying two primes, which is easy forwards but very hard to reverse. Adding them would be easy to undo. Line 3 should be n = p * q. The hashing library is called hashlib, not hashlip. Without the correct import, the program cannot use the one-way hash function sha256. Line 1 should be import hashlib.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 876–944) and word search (Modules 860–944).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
one-way functionFill in the Blanks
Spot the Error
Student with a class code? Join your class →