Reputation: 11
I am trying to do
key = struct.unpack('L', bytes_key)[0]
where bytes_key is b'\xa6\x0b\xddE'
and it works fine on my x32 machine, but whenever I am trying to execute it on x64 machine it getting me error.
Traceback (most recent call last):
File "unpacker.py", line 42, in <module> decompile(obj[1]) File "unpacker.py", line 13, in decompile f.write(decrypt_record(arg).content) File "crypt.py", line 61, in crypt.decrypt_record (crypt.c:2447) record.checksum = decrypt(record.checksum, checksum_key)
File "crypt.py", line 36, in crypt.decrypt (crypt.c:1821) key = struct.unpack('L', bytes_key)[0] struct.error: unpack requires a bytes object of length 8
Upvotes: 1
Views: 135
Reputation: 1096
You could try using "=" before the "L":
...
struct.unpack("=L", bytes_key)[0]
...
As per the documentation, it says:
Standard size depends only on the format character; see the table in the Format Characters section. Note the difference between '@' and '=': both use native byte order, but the size and alignment of the latter is standardized.
Upvotes: 1