Skip to content

Instantly share code, notes, and snippets.

@jowens
Created January 19, 2019 04:16
Show Gist options
  • Save jowens/1242d9b2dff0e4183c403e0c0c35f4a3 to your computer and use it in GitHub Desktop.
Save jowens/1242d9b2dff0e4183c403e0c0c35f4a3 to your computer and use it in GitHub Desktop.
codes = ['YAOONGPE', 'TEUZZYAE', 'TENNIPAE', 'LAXAALAA', 'YAEKPLAE', 'IEXGVYZA', 'YEXIKOYA', 'IPUGAGZP', 'GPKUAEZA',
'LOEKSAPA', 'ZPSLPXZA', 'PEEVAZTA', 'IAXVYEYE', 'ZAOKPZLE', 'GEOGNTAA', 'PEEKYPLA', 'GPEGKILA', 'PEKSVGLA']
test_code = 'ZEXPYGLA'
hex_map = dict()
hex_map['A'] = 0x0
hex_map['P'] = 0x1
hex_map['Z'] = 0x2
hex_map['L'] = 0x3
hex_map['G'] = 0x4
hex_map['I'] = 0x5
hex_map['T'] = 0x6
hex_map['Y'] = 0x7
hex_map['E'] = 0x8
hex_map['O'] = 0x9
hex_map['X'] = 0xA
hex_map['U'] = 0xB
hex_map['K'] = 0xC
hex_map['S'] = 0xD
hex_map['V'] = 0xE
hex_map['N'] = 0xF
rev_hex_map = 'APZLGITYEOXUKSVN'
code = test_code
print(hex(0x8000 + ((hex_map[code[3]] & 7) << 12) | ((hex_map[code[5]] & 7) << 8) | ((hex_map[code[4]] & 8) << 8) | (
(hex_map[code[2]] & 7) << 4) | ((hex_map[code[1]] & 8) << 4) | (hex_map[code[4]] & 7) | (hex_map[code[3]] & 8)))
print(((hex_map[code[1]] & 7) << 4) | ((hex_map[code[0]] & 8) << 4) | (
hex_map[code[0]] & 7) | (hex_map[code[5]] & 8))
print()
str = ''
for code in codes:
compare = ((hex_map[code[7]] & 7) << 4) | ((hex_map[code[6]] & 8) << 4) | (
hex_map[code[6]] & 7) | (hex_map[code[5]] & 8)
address = 0x8000 + ((hex_map[code[3]] & 7) << 12) | ((hex_map[code[5]] & 7) << 8) | ((hex_map[code[4]] & 8) << 8) | (
(hex_map[code[2]] & 7) << 4) | ((hex_map[code[1]] & 8) << 4) | (hex_map[code[4]] & 7) | (hex_map[code[3]] & 8)
data = ((hex_map[code[1]] & 7) << 4) | ((hex_map[code[0]] & 8) << 4) | (
hex_map[code[0]] & 7) | (hex_map[code[5]] & 8)
# we now have address and data
# now reverse address/data for 6 char
# address_6char = 0x8000 +
# ((n3 & 7) << 12)
# | ((n5 & 7) << 8) | ((n4 & 8) << 8)
# | ((n2 & 7) << 4) | ((n1 & 8) << 4)
# | (n4 & 7) | (n3 & 8);
# data_8char =
# ((n1 & 7) << 4) | ((n0 & 8) << 4)
# | (n0 & 7) | (n7 & 8);
# data_6char =
# ((n1 & 7) << 4) | ((n0 & 8) << 4)
# | (n0 & 7) | (n5 & 8);
code6 = ['?', '?', '?', '?', '?', '?']
code6[0] = rev_hex_map[(data & 7) | ((data >> 4) & 8)]
code6[1] = rev_hex_map[((data >> 4) & 7) | ((address >> 4) & 8)]
code6[2] = rev_hex_map[((address >> 4) & 7)]
code6[3] = rev_hex_map[((address >> 12) & 7) | (address & 8)]
code6[4] = rev_hex_map[(address & 7) | (address >> 8) & 8]
code6[5] = rev_hex_map[((address >> 8) & 7) | (data & 8)]
# print(code6, hex(data))
code6_str = ''.join(code6)
print(code6_str)
str = str + code6_str + '+'
print str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment