One-time pad
Encryption using a truly random key as long as the message, used only once. Never reused, it is unbreakable in theory, but the pad must be shared securely.
Understanding One-time pad in QCE Digital Solutions Unit 4
What it does: This check finds a key that is too short, which breaks the rule that the pad is as long as the message. A 2 GB video needs a 2 GB pad, which must also be shared securely, so it is impractical for large data. The pad must be at least as long as the message. If the key repeats, patterns appear and the cipher can be attacked. A predictable key gives an attacker something to guess. A truly random key leaves no pattern to exploit. Reusing a key lets an attacker compare the two ciphertexts and work out information about both messages. That is why it is called one-time.
Common mistakes: The key must be as long as the message. Looping over only 3 values gives a key shorter than the 5-number message. It should be for n in msg: so there is one random key value per message value. A one-time pad key must be exactly as long as the message. Subtracting 2 leaves the last two characters with no key value. It should be key = make_key(len(msg)).
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 17–88) and word search (Modules 17–125).
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-time padFill in the Blanks
Spot the Error
Student with a class code? Join your class →