about summary refs log tree commit diff
path: root/users/wpcarro/scratch/cryptopals/set1/c4.py
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/scratch/cryptopals/set1/c4.py')
-rw-r--r--users/wpcarro/scratch/cryptopals/set1/c4.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/users/wpcarro/scratch/cryptopals/set1/c4.py b/users/wpcarro/scratch/cryptopals/set1/c4.py
index 6775d73ec8cd..c546419a3388 100644
--- a/users/wpcarro/scratch/cryptopals/set1/c4.py
+++ b/users/wpcarro/scratch/cryptopals/set1/c4.py
@@ -2,11 +2,22 @@ import c3
 
 content = None
 with open('4.txt', 'r') as f:
-    c3.decode_cipher
     content = f.read().splitlines()
+if not content:
+    raise Error("Need content to proceed")
 
+xs = []
 for line in content:
     try:
-        print(c3.decode_cipher(line))
+        x = c3.decode_cipher(line)
+        if x: xs.append(x)
     except:
         continue
+
+freqs = c3.frequency_table()
+print(max(xs, key=lambda x: c3.score(x, freqs)))
+
+################################################################################
+# Answer
+################################################################################
+"Now that the party is jumping"