Initial Commit

This commit is contained in:
Roman Hergenreder
2018-12-04 12:54:01 +01:00
commit dd508a8100
16 changed files with 134 additions and 0 deletions

37
Day 4/decode.py Normal file
View File

@@ -0,0 +1,37 @@
#!/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)