Syntaktisch passt alles. Und es kommt auch das raus was rauskommen soll. Nur warum ist der Output von Zeile 3 so komisch ? Bug ?
Hier mein Code:
Code: Alles auswählen
plain = bytearray([0xA0,0x01,0x02,0x03,0x04])
print("Plain: ", plain)
otp1 = bytes([0x11,0xA7,0x93,0xFF,0xB0])
otp2 = bytes([0xAF,0xCE,0x73,0x01,0x6C])
cypr1 = bytearray(5)
cypr2 = bytearray(5)
cypr3 = bytearray(5)
for x in range(0,5):
xored = plain[x] ^ otp1[x]
cypr1[x] = xored
print("Cypr1: ", cypr1)
for x in range(0,5):
xored = cypr1[x] ^ otp2[x]
cypr2[x] = xored
print("Cypr2: ", cypr2)
for x in range(0,5):
xored = cypr2[x] ^ otp1[x]
cypr3[x] = xored
for x in range(0,5):
xored = cypr3[x] ^ otp2[x]
cypr3[x] = xored
print("Final: ", cypr3)
Code: Alles auswählen
Plain: bytearray(b'\xa0\x01\x02\x03\x04')
Cypr1: bytearray(b'\xb1\xa6\x91\xfc\xb4')
Cypr2: bytearray(b'\x1eh\xe2\xfd\xd8')
Final: bytearray(b'\xa0\x01\x02\x03\x04')
>>>