This exercise involves decrypting two different pieces of ciphertext using two different methods to find the encryption keys and the original plaintext messages.
To run the Java version:
cd <project_dir>
javac rotor96Crypto/*.java
java rotor96Crypto.KPA # to run the Known Plaintext Attack
java rotor96Crypto.COA # to run the Ciphertext Only AttackTo run the Python version:
cd <project_dir/python>
python KPA.py # to run the Known Plaintext Attack
python COA.py # to run the Ciphertext Only Attack- All of the secret messages have been encyrpted by an 8-rotor encryption machine called Rotor96Crypto.
- All keys have been taken from a file of common passwords called 'passwords'.
- The ciphertexts are stored in 'ciphertext1.txt' and 'ciphertext2.txt'.
- The first two letters of the plaintext are 'We' and it's stored in 'plaintext_start_chars.txt'.
- Two methods are used to decrypt the ciphertexts:
- Known Plaintext Attach (KPA): The first two letters of the plaintext are known.
- Ciphertext Only Attack (COA): Only the ciphertext is known.
Convert input character to a byte value in range [0, 95]:
For each rotor ( k ) (from 0 to 7):
After transformation, update rotor offset:
Final ASCII conversion:
For each rotor ( k ) (from 7 to 0):
Update rotor offset:
Final ASCII conversion:
Each rotor transformation introduces a key-dependent substitution, making the encryption scheme a polyalphabetic cipher similar to classical rotor-based encryption machines.
Given a chunk of ciphertext with the first two characters of the plaintext, perform a dictionary attach to find the key. Use this key to decode the rest of the message.
Given another chunk of ciphertext but with no information about the plaintext, perform a dictionary attack but this time decide whether a key produces the correct plaintext given that the plaintext is an English message.