Uploaded December 2021 | Updated November 2026, 1 hour ago
00:00 - Intro
00:35 - Describing frequency analysis
01:10 - Downloading a book from Project Gutenberg and counting character frequencies
03:20 - Looking at frequency counts by character set
04:10 - Starting the solution script, talking about Black ("The uncompromising Python code formatter")
04:45 - Writing a function to score a plaintext's plausibility by its frequency counts
06:58 - Writing the XOR cipher cracking function (first version)
07:55 - How (and why) to use infinity in Python
10:30 - Writing crack_xor_cipher_worse so we can view top 5 candidate plaintexts
11:20 - Testing the cracking function
12:05 - Talking about ASCII table layout
13:37 - Talking about sample sizes, swapping out frequency count dictionary
15:20 - Modifying "score_text" to only count lowercase frequencies
15:45 - Solving the challenge, starting to refactor
16:20 - Introducing dataclasses and creating ScoredGuess dataclass
20:30 - Rewriting crack_xor_cipher to use ScoredGuess
23:12 - Optimizing the scoring algorithm
27:30 - Testing and benchmarking the optimized algorithm (it works really well!)
Further reading:
en.wikipedia.org/wiki/Substitution_cipher
en.wikipedia.org/wiki/Frequency_analysis
python.org/dev/peps/pep-0008
github.com/psf/black
en.wikipedia.org/wiki/Etaoin_shrdlu
en.wikipedia.org/wiki/ASCII#Design_considerations
docs.python.org/3/library/dataclasses.html
ipython.readthedocs.io/en/stable/interactive/magics.html#magic-timeit
00:00 - Intro
00:35 - Describing frequency analysis
01:10 - Downloading a book from Project Gutenberg and counting character frequencies
03:20 - Looking at frequency counts by character set
04:10 - Starting the solution script, talking about Black ("The uncompromising Python code formatter")
04:45 - Writing a function to score a plaintext's plausibility by its frequency counts
06:58 - Writing the XOR cipher cracking function (first version)
07:55 - How (and why) to use infinity in Python
10:30 - Writing crack_xor_cipher_worse so we can view top 5 candidate plaintexts
11:20 - Testing the cracking function
12:05 - Talking about ASCII table layout
13:37 - Talking about sample sizes, swapping out frequency count dictionary
15:20 - Modifying "score_text" to only count lowercase frequencies
15:45 - Solving the challenge, starting to refactor
16:20 - Introducing dataclasses and creating ScoredGuess dataclass
20:30 - Rewriting crack_xor_cipher to use ScoredGuess
23:12 - Optimizing the scoring algorithm
27:30 - Testing and benchmarking the optimized algorithm (it works really well!)
Further reading:
en.wikipedia.org/wiki/Substitution_cipher
en.wikipedia.org/wiki/Frequency_analysis
python.org/dev/peps/pep-0008
github.com/psf/black
en.wikipedia.org/wiki/Etaoin_shrdlu
en.wikipedia.org/wiki/ASCII#Design_considerations
docs.python.org/3/library/dataclasses.html
ipython.readthedocs.io/en/stable/interactive/magics.html#magic-timeit








