master
1import base64
2import string
3import collections
4import csv
5import random
6from math import sqrt
7import simple_crypto as sc
8
9t1 = """Defeat at the castle seems to have utterly disheartened
10 King Arthur. The ferocity of the French taunting took him completely
11 by surprise, and Arthur became convinced that a new strategy
12 was required if the quest for the Holy Grail were to be brought
13 to a successful conclusion. Arthur, having consulted his closest
14 knights, decided that they should separate, and search for the Grail
15 individually. Now, this is what they did"""
16t2 = """Oh king, eh, very nice. An' how'd you get that, eh? By
17 exploitin' the workers -- by 'angin' on to outdated imperialist dogma
18 which perpetuates the economic an' social differences in our society!
19 If there's ever going to be any progress"""
20t3 = """Listen, lad. I've built this kingdom up from nothing. When
21 I started here, all there was was swamp. All the kings said I was
22 daft to build a castle in a swamp, but I built it all the same,
23 just to show 'em. It sank into the swamp. So, I built a second one.
24 That sank into the swamp. So I built a third one. That burned down,
25 fell over, then sank into the swamp. But the fourth one stayed up.
26 An' that's what your gonna get, lad -- the strongest castle in these
27 islands."""
28
29text_filter = sc.translator (keep=string.ascii_letters)
30t1 = text_filter("".join(t1.split())).lower()
31t2 = text_filter("".join(t2.split())).lower()
32t3 = text_filter("".join(t3.split())).lower()
33k1 = random.choice(string.ascii_lowercase)
34k2 = random.choice(string.ascii_lowercase)
35k3 = random.choice(string.ascii_lowercase)
36print k1,k2,k3
37gk1 = sc.freq_decode_char_xor (sc.xor_char (t1, k1))
38gk2 = sc.freq_decode_char_xor (sc.xor_char (t2, k2))
39gk3 = sc.freq_decode_char_xor (sc.xor_char (t3, k3))
40print gk1,gk2,gk3