From a9efab946d4bdee0553014a364cf3276b756d378 Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Sun, 29 Dec 2019 18:33:49 +0100 Subject: [PATCH] Day 20 fixed --- Day 20/decode.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Day 20/decode.py b/Day 20/decode.py index 0051da4..980c818 100644 --- a/Day 20/decode.py +++ b/Day 20/decode.py @@ -1,5 +1,7 @@ -byte_300 = [0xCE, 0x55, 0x95, 0x4E, 0x38, 0x0C5, 0x89, 0x0A5, 0x1B, 0x6F, 0x5E, 0x25, 0x0D2, 0x1D, 0x2A, 0x2B, 0x5E, 0x7B, 0x39, 0x14, 0x8E, 0x0D0, 0x0F0, 0x0F8, 0x0F8, 0x0A5, 0x00] +byte_300 = [0xCE, 0x55, 0x95, 0x4E, 0x38, 0x0C5, 0x89, 0x0A5, 0x1B, 0x6F, 0x5E, 0x25, 0x0D2, 0x1D, 0x2A, 0x2B, 0x5E, 0x7B, 0x39, 0x14, 0x8E, 0x0D0, 0x0F0, 0x0F8, 0x0F8, 0x0A5] + +BUFFER_LENGTH = len(byte_300) with open("PS4UPDATE.PUP", "rb") as f: @@ -8,12 +10,12 @@ with open("PS4UPDATE.PUP", "rb") as f: while True: f.seek(v14) - input = bytes(f.read(27)) - for i in range(27): + input = bytes(f.read(BUFFER_LENGTH)) + for i in range(BUFFER_LENGTH): v29[i] = (v29[i] ^ input[i]) v14 += 4919 - if v14 == 24201480: # 4920 times + if v14 == 24201480: # 4919 times break print("".join(chr(x) for x in v29))