forked from ynohtna92/1FLAMEN6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuzzle_decoder.py
More file actions
207 lines (187 loc) · 2.62 KB
/
puzzle_decoder.py
File metadata and controls
207 lines (187 loc) · 2.62 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env python
# Author: A_Dizzle
# Date: 04/02/2018
# 1FLAMEN6 Puzzle Decoder https://twitter.com/coin_artist/status/583979278238359552
import math
def string_decode(input, length=8):
input_l = [input[i:i+length] for i in range(0,len(input),length)]
return ''.join([chr(int(c,base=2)) for c in input_l])
# Ribbon Key
key = "011010"
# 4-bit Flame encoded Chunks
# short (0) or tall (1)
# yellow (0) or red (1) border
# narrow (0) or wide (1)
# purple (0) or green (1) interior
# Read clockwise around the picture frame from inside edge starting from the top left
# once a full loop is made continue on the outer edge counter-clockwise
flames = [
"0010", # Top Inner (left -> right)
"1011",
"1001",
"0101",
"1010",
"1110",
"0001",
"1100",
"1001",
"0001",
"1110",
"0011",
"0100",
"0101",
"1000",
"0110",
"1110",
"1110",
"0001",
"1011",
"1101",
"0011",
"1110",
"1110",
"0000",
"0001",
"1000",
"1010",
"1011", # Right Inner (top -> bottom)
"1010",
"0000",
"1000",
"1100",
"1000",
"1111",
"1110",
"0110",
"1001",
"1101",
"0100",
"1111",
"1011",
"0001",
"1011",
"1100",
"1111",
"1110",
"1110",
"0001",
"0000",
"1001",
"0011",
"1101", # Bottom Inner (right -> left)
"0001",
"0101",
"0001",
"1110",
"1110",
"1111",
"0011",
"0010",
"0010",
"1001",
"0100",
"1100",
"1110",
"0011",
"1001",
"1001",
"1110",
"1010",
"1101",
"0101",
"1101",
"1110",
"1101",
"1100",
"1101",
"0010",
"1111",
"1001",
"1110",
"1100",
"1100",
"0000",
"0001", # Left Inner (bottom -> top)
"1101",
"1110",
"1111",
"0101",
"0001",
"1111",
"1001",
"0001",
"1110",
"1110",
"0000",
"1011",
"1100", # Left Outer (top -> bottom)
"0001",
"1111",
"1000",
"0001",
"1101",
"1101",
"0010",
"1111", # Bottom Outer (left -> right)
"0100",
"0000",
"0000",
"1110",
"0100",
"1010",
"1000",
"0000",
"1110",
"1101",
"1110",
"1110",
"1011",
"0001",
"0001",
"1111", # Right Outer (bottom -> top)
"0110",
"1010",
"0010",
"0010",
"0010",
"1110",
"1011",
"1100",
"1111",
"0101",
"0000",
"1111", # Top Outer (right -> left)
"0010",
"1110",
"1101",
"0010",
"0010",
"1001",
"1110",
"1111",
"0101",
"0000",
"1101",
"1110",
"0111",
"1010",
"1011",
"0101",
"0001",
]
# Concatenate binary string
data = ""
for x in flames:
data = data + x
# Generate XOR binary string
xor = int(math.ceil(len(data)/6.0)) * key
# print(data)
# print(xor)
# XOR data and xor strings together
results = ""
for i,c in enumerate(data):
results = results + str(int(c) ^ int(xor[i]))
# print(results)
# Decode result as ascii string
decoded_str = string_decode(results)
print(decoded_str)