#!/usr/bin/python

pirates = ['0' for i in range(48)]

p = ''.join(pirates)
s = '::)"<.vd]!&a{":r>Qyh 7';
length = len(s)

f='HV18-';

def subnum(i):
    return int(p[i*2:i*2+2])

for i in range(length):
    a = ord(s[i])
    b = subnum(i)
    f += chr(a ^ b)

print(f)

# indizes: 4, 9, 14, 19
# xxxx-xxxx-xxxx-xxxx
correctKey = "00000000"
for i in range(4):
    pos = 4 + i*5
    key = ord(s[pos]) ^ ord('-')
    correctKey += "%02d%s" % (key, "00000000")

data = [correctKey[i:i+4] for i in range(0, len(correctKey), 4)]

print(correctKey)
print(data)

js = ""
for i in range(len(data)):
    js += "document.getElementById('pirate%02d').value='%s';\n" % (i + 1, data[i])
print(js)
