summaryrefslogtreecommitdiff
path: root/059.py
blob: 449afb7b64e9e9e64d0f4e7e8d7dc8488cb45ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import string

keys = []

for a in string.lowercase:
	for b in string.lowercase:
		for c in string.lowercase:
			keys.append(a+b+c)

f = open('059.txt', 'r')
content = f.read().split(',')
f.close()

cipher = [ int(i) for i in content ]
cipher_len = len(cipher)

for key in keys:
	decoded = ""
	for p in range(0, cipher_len):
		decoded += chr(cipher[p] ^ ord(key[p%3]))
	if decoded.find(" the ") != -1 and decoded.find(" and ") != -1:
		break

#print decoded
#print key

print sum([ ord(x) for x in decoded ])