diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4a96c22 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +source .venv/bin/activate \ No newline at end of file diff --git a/answers.md b/answers.md index f125e69..ab9b74a 100644 --- a/answers.md +++ b/answers.md @@ -4,22 +4,26 @@ 0. `secrets/secret0.txt` is encrypted using a Caesar Cipher. What is its secret number? - +78 1. `secrets/secret1.txt` is encrypted using a Caesar Cipher. What is its secret number? - +1 2. `secrets/secret2.txt` is encrypted using a Caesar Cipher. What is its secret number? - +44 3. `secrets/secret3.txt` is encrypted using a Caesar Cipher. What is its secret number? - +59 4. `secrets/secret4.txt` is encrypted using a Caesar Cipher. What is its secret number? - +32 ## Checkpoint 2 5. What is the polyalphabetic secret word? +PYTHON + 6. Decrypt this message, which was encrypted using the same secret word: "EbZhdaV[h^bTpchhQnhig]X[VmhhRP]ftXVnRfjVY]fgtO_X](" + +The treasure is a worthless ball of aluminum foil. \ No newline at end of file diff --git a/caesar_cracker.py b/caesar_cracker.py new file mode 100644 index 0000000..d449c47 --- /dev/null +++ b/caesar_cracker.py @@ -0,0 +1,24 @@ +from easybits import Bits +from collections import Counter +from ciphers.caesar import CaesarCipher + +def crack_caesar(ciphertext): + counted = Counter(ciphertext) + charlist = list(counted.keys()) + commonchar = charlist[0] + for char in charlist: + if counted[char] > counted[commonchar]: + commonchar = char + return Bits(commonchar).int - Bits(" ").int + +with open("secrets/secret4.txt") as f: + ciphertext = f.read() + + + +secret = crack_caesar(ciphertext) +cipher = CaesarCipher(secret) +plaintext = cipher.decrypt(ciphertext) + +print(secret) +print(plaintext)