Cipher Visualizer
SEC-101 interactive (Weeks 4-5) -- XOR encryption, Caesar and substitution ciphers, frequency-analysis cracking -- return to SEC-101
This visualizer supports SEC-101 Weeks 4 and 5 (Cryptography I and II). Each tab targets one classical cipher concept that appears in picoCTF and in the foundations of modern cryptography. Use it alongside Lab 3 (Crypto Warm-Up): Tab 1 shows why repeating-key XOR is the most common beginner challenge pattern; Tab 2 connects the Caesar shift to a general substitution cipher; Tab 3 gives you the cracking tool.
These are classical ciphers, not the AES-GCM or ChaCha20-Poly1305 systems used in production. They appear here for one purpose: to make why modern ciphers are needed concrete and measurable rather than asserted.
Bit-level XOR for byte 0 -- click any byte above to inspect it
Why repeating-key XOR fails
When the key is the same length as the plaintext, each key byte is used exactly once. This approximates the one-time-pad construction, which additionally requires the key to be truly random and never reused.
When the key is shorter than the plaintext, it repeats. Every byte at positions 0, n, 2n, ... is XORed with the same key byte. If you know even one plaintext character at position i, you recover key byte i mod n directly. In CTF challenges, the "known-plaintext attack" on repeating-key XOR is a two-step process: (1) guess the key length from coincidence-index peaks, (2) use frequency analysis on every n-th byte to recover each key byte independently.
Try the repeating-key example. The word ATTACK AT DAWN with key KEY produces bytes at positions 0, 3, 6, 9, 12 all XORed with K. If you assume the message starts with a space, XOR the first ciphertext byte with 0x20 (space) to get the first key byte immediately.
Caesar is a special case of substitution
A Caesar cipher shifts every letter by a fixed number of positions in the alphabet. There are only 26 possible shifts, so exhaustive search (trying all 26) breaks it instantly. The mapping table above shows the complete substitution: every letter maps to exactly one ciphertext letter, and vice versa.
A general substitution cipher randomizes the 26-letter mapping rather than shifting it uniformly. There are 26! possible mappings, so brute force is not feasible. However, a fixed letter-to-letter mapping means the letter frequency distribution of the ciphertext mirrors the plaintext -- just with relabeled letters. The most common letter in English is E; if the most common letter in the ciphertext is X, then X is standing in for E. Move to Tab 3 to see this attack in action.
Ciphertext letter frequencies (sorted by count, descending)
Reference English frequencies (E T A O I N S H R D L U ...)
What frequency analysis reveals
In English, E appears about 12.7% of the time and T about 9.1%. The top six letters (E T A O I N) account for over 45% of all letters. A Caesar cipher changes which letter is labeled E, but it cannot change how often the most common letter appears.
To crack a Caesar cipher: find the most common letter in the ciphertext, assume it maps to E, and compute the shift as (cipher_peak - E + 26) mod 26. For the longer example, this gives the correct shift in one step. For short texts, try the top two or three candidates. The shift slider above decrypts live as you drag.
A general substitution cipher has the same weakness. Every high-frequency ciphertext letter must map to a high-frequency plaintext letter. Combined with common digrams (TH, HE, IN, ER) and trigrams (THE, AND, ING), a monoalphabetic substitution over one paragraph of text can be cracked by hand with no computational tools.