XOR, exclusive OR, produces 1 where two input bits differ and 0 where they agree. The code stage used it on bytes; here a puzzle fixes one byte and one key so you can trace the operation by hand. A byte has eight bits. Hexadecimal writes those bits compactly as two digits.
The key 0x01 is the integer byte 1, written in hex; it is not the text character "1". The same key applied twice restores the starting byte because each selected bit flips twice. That reversible property checks your arithmetic. A tiny published key does not provide useful secrecy.
Before you begin
- Recommended first
- Hex, Base64, and XOR in code, Encoding, hashing, and encryption, Notes: scope, command, result, time, Classical ciphers
- Estimated time
- 15 min reading, 15 min activity. Setup and optional practice may take longer.
- Where you work
- Read the printed evidence in a desktop or mobile browser and keep notes on paper or in a text editor. No installation, recovery tool, GPU, real password, live lookup or external account is required. Any later optional tool setup is outside the estimates.
- Without a lab
- All evidence needed for the activity appears on this page. Copy it into notes if downloads are unavailable. Read the labeled model and predict each result; a paper trace practises the reasoning while tool operation waits for a lab. Reading needs no JavaScript. Answer checking needs JavaScript and a secure context; saving progress also needs usable browser storage.
After this lesson you can:
- Combine one ciphertext byte with the stated key byte.
- Write the result as two hex digits.
- XOR that result with the same key byte and recover the ciphertext byte.
01Example
Original bit model, with a worked byte different from the guided and independent bytes.
Cipher byte 0x40: 0100 0000
Key byte 0x01: 0000 0001
XOR result 0100 0001 = 0x41
Second XOR with 0x01 restores 0100 0000 = 0x40.02Only the low bit moves
With key 0x01 only the rightmost bit has a matching key bit of 1. Bits above it stay unchanged; the rightmost bit flips. This is a consequence of this key’s bits, not a rule that every XOR operation adds one.
Line up equal-width rows before combining them. For a bit paired with zero, XOR keeps it. For a bit paired with one, XOR reverses it. Record the result as exactly two hex digits when that is the requested format.
Combine aligned bits with a stated key byte and use a second pass to check the result.Model. A teaching model drawn by hand. It shows the idea, not real tool output.
Read the full explanation below.
0x400x01Not establishedPass 0. Equal bits give 0; different bits give 1.
The cipher byte is 0x40 and the key byte is 0x01.
Follow the explanation
- The cipher byte is 0x40 and the key byte is 0x01.
- 40 XOR 01 gives 41; only the low bit changes.
- 41 XOR 01 restores 40 with the same key.
Read every state and value
1. The cipher byte is 0x40 and the key byte is 0x01.
- Sample
- Cipher byte 40 and key 01
- Selected Bit
- 7
- Result Byte
- Not established
- Pass
- 0
2. 40 XOR 01 gives 41; only the low bit changes.
- Sample
- Cipher byte 40 and key 01
- Selected Bit
- 7
- Result Byte
- 65
- Pass
- 1
3. 41 XOR 01 restores 40 with the same key.
- Sample
- Cipher byte 40 and key 01
- Selected Bit
- 7
- Result Byte
- 64
- Pass
- 2
03Recover the activity byte
The guided ciphertext is 0x52 with key 0x01. The printed bit table provides all evidence; no script is needed.
Label: hand-worked XOR bit table. The optional file contains the three-byte sequence listed below. Historical script observations are recorded separately.
Worked: 0x40 XOR 0x01.
0100 0000
0000 0001
0100 0001 = 0x41
Second pass with 0x01 returns 0x40.
Activity: 0x52 XOR 0x01.
0101 0010
0000 0001
0101 0011 = 0x53
Second pass with 0x01 returns 0x52.
Optional three ciphertext bytes in xor-puzzle.bin: 11 22 33.
Same key 0x01. Predicted plaintext hex: 10 23 32.
- Write 0x52 as 0101 0010 and align 0000 0001 beneath it.
- Apply the bit rule column by column. Compare your result with 0101 0011, or hex 53.
- Apply the same key again. Recovering 0101 0010 checks this round trip; record both transformations.
- Stop after the fixed-key comparison. The optional raw bytes are a separate sequence, not a reason to try more keys.
04Optional challenge
The optional file contains ciphertext bytes 11 22 33 in hex; the text table supplies the same values. In about ten minutes, apply key 01 to each. Check against 10 23 32, then make a second pass to recover the original sequence. This exercise needs no file execution.
05Fresh cases for the checks
Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.
XOR card A: independent byteOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Cipher byte 0x64 = 0110 0100.
Key byte 0x01 = 0000 0001.
XOR gives 1 where aligned bits differ, 0 where they agree.
Reverse card B: separate first-pass resultOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
A first XOR pass with key 0x01 produced byte 0x77 = 0111 0111.
Apply that same key once more to recover this card’s starting byte.
Width card C: independent byte with a low bit already setOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Cipher byte 0x2f = 0010 1111.
Key byte 0x01 = 0000 0001.
Write the result as a byte, retaining two hex positions.
06Explain the evidence and its limit
Optional self-check: draw two aligned eight-bit XOR passes and explain why the starting byte returns.
Review it: apply the bit rule, distinguish byte 0x01 from the character 1, preserve byte width and avoid treating reversibility as secure encryption.
07Common mistakes
If the result is 41, you used the worked starting byte. Recopy the guided 52 before calculating.
If the operand is a text character, return to the eight-bit key 0000 0001. Character encodings and integer values are different representations.
If XOR seems always to increase a number, test a starting byte whose lowest bit is already 1; this key clears that bit.
References
- Python 3.12: binary bitwise operations
Section 6.9 defines integer bitwise XOR, written ^ in Python.