finds.dev← search

// the find

asweigart/codebreaker

★ 362 · Python · updated Jul 2021

"Hacking Secret Ciphers with Python" programs

Companion code for Al Sweigart's book 'Hacking Secret Ciphers with Python', covering classical ciphers (Caesar, Vigenere, RSA, affine, transposition) and their corresponding breakers. It's for beginners learning cryptography concepts through readable Python, not for anyone building anything that needs to be secure. The code is intentionally simple — that's the point.

The collection is unusually complete: for nearly every cipher there's an encrypt module, a decrypt module, and a dedicated breaker — you can see the full attack surface alongside the implementation. The Rabin-Miller primality test and RSA key generation are implemented from scratch, which is a better teaching tool than wrapping a library. A unit test file exists, which is more than most beginner-level crypto repos bother with. Frankenstein.txt as a corpus for frequency analysis is a nice touch — big enough to be statistically useful.

Last touched in 2021, and the author explicitly isn't accepting refactors, so bit-rot is permanent by design — Python 3.10+ type hints, f-strings, and modern idioms won't appear here. The included RSA private key in the repo is a bad habit to model for beginners, even as a sample. There's no packaging or install instructions; everything is meant to be run as loose scripts from the same directory, which will confuse anyone who tries to import across files. The 'detect English' heuristic is brittle and the implementation is never explained, which is a gap in a book that otherwise explains everything.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →