Skip to main content
Back to projects

Byte Frequency Analysis

Cryptanalysis

Fundamentals Interactive
Python data analysis
Interactive demo letter frequency analysis in your browser

Paste some text and it counts how often each letter appears, then compares the shape to typical English (where "E" dominates). That same idea is the first step in breaking a simple Caesar cipher: if the most common letter is probably "E", you can guess the shift.

How it works

  1. 1 Read the text
  2. 2 Count each letter
  3. 3 Rank by frequency
  4. 4 Compare to English and guess the shift

How it works

In natural language, some symbols appear far more often than others — in English, “E” leads by a wide margin. Counting bytes or letters and ranking them exposes that distribution, which is the first step in breaking a simple substitution or Caesar cipher.

Building it, step by step

1. Count symbols

Every letter is tallied, ignoring case and non-letters.

2. Rank by frequency

The tallies are sorted so the dominant symbols rise to the top.

3. Guess the shift

If the most common letter is assumed to encode “E”, the difference in positions is the Caesar shift.

What I learned

Frequency analysis works because plaintext is not random. The same idea applies to raw bytes — a known file format leaves a statistical fingerprint — which is why real encryption must produce output indistinguishable from noise.