Skip to content

Commit c9271df

Browse files
isHarryhK0lb3
authored andcommitted
refactor(helpers): inline to_uint4_array in ArchiveStorageDecryptor
1 parent 670c84e commit c9271df

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

UnityPy/helpers/ArchiveStorageManager.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ def brute_force_key(
6161
return None
6262

6363

64-
def to_uint4_array(source: bytes, offset: int = 0):
65-
buffer = bytearray(len(source) * 2)
66-
for j in range(len(source)):
67-
buffer[j * 2] = source[offset + j] >> 4
68-
buffer[j * 2 + 1] = source[offset + j] & 15
69-
return buffer
70-
71-
7264
class ArchiveStorageDecryptor:
7365
unknown_1: int
7466
index: bytes
@@ -99,7 +91,9 @@ def __init__(self, reader: EndianBinaryReader) -> None:
9991
raise Exception(f"Invalid signature {signature} != {UNITY3D_SIGNATURE}")
10092

10193
data = decrypt_key(self.key, self.data, DECRYPT_KEY)
102-
data = to_uint4_array(data)
94+
data = bytes(
95+
nibble for byte in data for nibble in (byte >> 4, byte & 0xF)
96+
)
10397
self.index = data[:0x10]
10498
self.substitute = bytes(
10599
data[0x10 + i * 4 + j] for j in range(4) for i in range(4)

0 commit comments

Comments
 (0)