Skip to content

Instantly share code, notes, and snippets.

@synap5e
Created July 28, 2013 01:33
Show Gist options
  • Save synap5e/6096993 to your computer and use it in GitHub Desktop.
Save synap5e/6096993 to your computer and use it in GitHub Desktop.
# This array is used to encode and decode the resource files
data_key = [
0x00001092, 0x0000254F, 0x00000348, 0x00014B40, 0x0000241A, 0x00002676,
0x0000007F, 0x00000009, 0x0000250B, 0x0000018A, 0x0000007B, 0x000012E2,
0x00007EBC, 0x00005F23, 0x00000981, 0x00000011, 0x000085BA, 0x0000A566,
0x00001093, 0x0000000E, 0x0002D266, 0x000007C3, 0x00000C16, 0x0000076D,
0x00015D41, 0x000012CD, 0x00000025, 0x0000008F, 0x00000DA2, 0x00004C1B,
0x0000053F, 0x000001B0, 0x00014AFC, 0x000023E0, 0x0000258C, 0x000004D1,
0x00000D6A, 0x0000072F, 0x00000BA8, 0x000007C9, 0x00000BA8, 0x0000131F,
0x000C75C7, 0x0000000D
]
def swap(data, index1, index2):
temp = data[index1]
data[index1] = data[index2]
data[index2] = temp
def encoder(data, decode):
data = bytearray(data)
size = len(data)
r = range(size)
if decode:
r = reversed(r)
for i in r:
location = data_key[i % 44] + i
swap(data, i, location % size)
for i in range(size):
data[i] = 0xFF - data[i]
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment