Skip to content

Commit 555c6b7

Browse files
committed
Added a decoder to the cipher Python script
1 parent 7fb3088 commit 555c6b7

1 file changed

Lines changed: 54 additions & 12 deletions

File tree

Unity/Astral Codex/Assets/Astral Codex Translation.ipynb

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,61 @@
1212
"name": "stdin",
1313
"output_type": "stream",
1414
"text": [
15-
" xml\n"
15+
" mode\n"
1616
]
1717
},
1818
{
1919
"name": "stdout",
2020
"output_type": "stream",
2121
"text": [
22-
"XML Mode: False\n"
22+
"Decoding\n"
2323
]
2424
},
2525
{
2626
"name": "stdin",
2727
"output_type": "stream",
2828
"text": [
29-
" thank you\n"
29+
" })& >;\"[* };|%[/\" ;/|&]([{)\n"
3030
]
3131
},
3232
{
3333
"name": "stdout",
3434
"output_type": "stream",
3535
"text": [
36-
"});/% ^?.\n"
36+
"THE MAGIC TALKING ANLERFISH\n"
37+
]
38+
},
39+
{
40+
"name": "stdin",
41+
"output_type": "stream",
42+
"text": [
43+
" . >[{{&_ ; \"\n"
44+
]
45+
},
46+
{
47+
"name": "stdout",
48+
"output_type": "stream",
49+
"text": [
50+
"U MISSEJ A G\n"
51+
]
52+
},
53+
{
54+
"name": "stdin",
55+
"output_type": "stream",
56+
"text": [
57+
" })& >;\"[* };|%[/\" ;/\"|&]([{)\n"
58+
]
59+
},
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"THE MAGIC TALKING ANGLERFISH\n"
3765
]
3866
}
3967
],
4068
"source": [
41-
"key = {\n",
69+
"keys = {\n",
4270
" 'A': (';'),\n",
4371
" 'B': ('@'),\n",
4472
" 'C': ('*'),\n",
@@ -69,21 +97,35 @@
6997
"}\n",
7098
"\n",
7199
"xmlMode = True\n",
100+
"encode = True\n",
72101
"while True:\n",
73102
" text = input()\n",
74103
" if text.upper()==\"Q\":\n",
75104
" break\n",
76-
" if text.upper()==\"XML\":\n",
105+
" elif text.upper()==\"XML\":\n",
77106
" xmlMode = not xmlMode\n",
78107
" print(\"XML Mode: \"+str(xmlMode))\n",
79108
" continue\n",
109+
" elif text.upper()==\"MODE\":\n",
110+
" encode = not encode\n",
111+
" if encode:\n",
112+
" print(\"Encoding\")\n",
113+
" else:\n",
114+
" print(\"Decoding\")\n",
115+
" continue\n",
80116
" output = \"\"\n",
81-
" for i in text:\n",
82-
" decoded = key[i.upper()]\n",
83-
" if xmlMode:\n",
84-
" output+=decoded[0]\n",
117+
" for char in text:\n",
118+
" if encode:\n",
119+
" encoded = keys[char.upper()]\n",
120+
" if xmlMode:\n",
121+
" output+=encoded[0]\n",
122+
" else:\n",
123+
" output+=encoded[min(1,len(encoded)-1)]\n",
85124
" else:\n",
86-
" output+=decoded[min(1,len(decoded)-1)] \n",
125+
" for key, value in keys.items():\n",
126+
" if value[len(value) - 1] == char:\n",
127+
" output += key\n",
128+
" break\n",
87129
" print(output)"
88130
]
89131
},
@@ -120,7 +162,7 @@
120162
"name": "python",
121163
"nbconvert_exporter": "python",
122164
"pygments_lexer": "ipython3",
123-
"version": "3.11.6"
165+
"version": "3.11.9"
124166
}
125167
},
126168
"nbformat": 4,

0 commit comments

Comments
 (0)