Lesson 1 of 6

The single-layer key

Goal

Try every key and pick the one closest to real text

01

Explanation

This is the first challenge, and its hints give away less than the ones in the lessons. You have a message that was XORed with a single-byte key you don't know, and your job is to recover both the key and the message with your own code.

There are only 256 possible keys, so you can try them all. But many keys produce output made entirely of printable characters that still isn't readable text, so printable output alone isn't enough. Also note that chr(b).isalpha() is true for some bytes above 0x7f that look like letters, so count only lowercase English letters and spaces, not everything that method treats as a letter. The messages here are lowercase English sentences with spaces between the words, so the right key is the one whose output looks most like such a sentence.

02

Your task

Write a function crack(cipher) that returns the tuple (key, plaintext): the key, then the decrypted text as bytes. The checks try it on other messages with other keys, so copying the answer for the message in the code won't help.

Checks

5 checks
  1. Recovers the key from a hidden message
  2. Decrypts another hidden message
  3. Tells an English sentence apart from letter-like symbols
  4. Recognizes a message that isn't encrypted
  5. Decrypts a message with digits into printable characters
03

Hints

0/3
Track lessons0 of 6 done

Six challenges of rising difficulty where you reverse a check function or bytecode and extract the key with your own code, not by copying it.

Advanced level, 6 lessons, 2 hours in total.

main.py
OutputPython (Pyodide)

Loading Python. This only happens once. Your browser keeps it after that.

–/5

Checks start once the environment is ready.

5 checks listed under “Your task”.

Track lessons0 of 6 done

Six challenges of rising difficulty where you reverse a check function or bytecode and extract the key with your own code, not by copying it.

Advanced level, 6 lessons, 2 hours in total.