# Breaking Vigenere

And other fun with cryptography

I’ve been messing around with some basic cryptography challenges ever since DEFCON, which was a ton of fun and very informative. The most recent challenge involved breaking a Vigenere cipher (also known as a repeating key XOR).

Here’s the basic algorithm:

Nothing informative here. I just felt like I looked like Hackerman while doing this. I’m highly caffeinated right now!

- Calculate normalized Hamming distances for various key sizes, and take the smallest one.
- Chunk cipher text into key-sized chunks.
- Transpose the chunk bytes.
- Find the single-byte XOR key for each transposed chunk with frequency analysis.
- Concatenate the keys, and find your plain text.
- ???
- Profit!

Fun stuff! So satisfying to see the plain text at the end of a challenge.

Here’s some of the code I wrote to do all of this (minus the profiting part): egyptiankarim/matasano