Skip to content

Instantly share code, notes, and snippets.

@jowens
Created January 19, 2019 02:17
Show Gist options
  • Save jowens/0a2f4dbc7876d18fbcd385d2f6b67ce8 to your computer and use it in GitHub Desktop.
Save jowens/0a2f4dbc7876d18fbcd385d2f6b67ce8 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
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()
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)
print(hex(address), hex(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment