Three applied cryptography challenges, each broken down with a write-up of
the approach (descriptionN.txt) and a working Python solution
(solutionN.py).
description1.txt / solution1.py
Implements CBC-mode decryption by hand using only an AES-ECB cipher object: decrypt each 16-byte block with ECB, then XOR the result with the previous ciphertext block (or the IV, for the first block), and finally strip PKCS7 padding.
description2.txt / solution2.py
Exploits the classic "two-time pad" flaw: when the same key/IV (and therefore the same keystream) encrypts two different messages, XORing one ciphertext with its known plaintext recovers the keystream, which can then be XORed against the other ciphertext to recover its plaintext.
description3.txt / solution3.py
Brute-forces a collision in a small custom hash function (ds_hash):
randomly generate 256-character messages, hash them, and check for two
different messages that map to the same hash.
pip install cryptography
(solution2.py and solution3.py use only the standard library.)