-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_atbash.py
62 lines (45 loc) · 971 Bytes
/
1_atbash.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# AtBash cypher
m = "" # this can be any string of ASCII characters, of any length
k = # unused in this cipher
m_ord = [] # this variable captures the message as encoded into its ascii number, for ease of transformation by the enc function
c_ord = []
c = ""
m_proof = ""
m_ord_proof = []
c_ord_proof = []
c_proof = ""
## mutate m into numbers
m = m.upper()
for x in m:
m_ord.append(ord(x) - 64)
print(m_ord)
## define enc
def enc(z):
for x in z:
c_ord.append(27 - x + 64)
## Enc
enc(m_ord)
print(c_ord)
## Turn c back into letters
for x in c_ord:
c += chr(x)
print c
## mutate c into numbers
for x in c:
c_ord_proof.append(ord(x))
print(c_ord_proof)
# define Dec
def dec(z):
for x in z:
m_ord_proof.append(27 - x + 64)
# Dec(c)
dec(c_ord_proof)
print(m_ord_proof)
## Turn m back into letters
for x in m_ord_proof:
m_proof += chr(x)
print(m_proof)
if m_proof == m:
print("Heck yeah, proofed")
else:
print("Fail Whale")