aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmakecab.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/makecab.py b/makecab.py
index befa94a..77c1e4f 100755
--- a/makecab.py
+++ b/makecab.py
@@ -34,7 +34,11 @@ def packtime(h,m,s):
34 return ((h << 11) | (m << 5) | (s >> 1)) 34 return ((h << 11) | (m << 5) | (s >> 1))
35 35
36def checksum(data): 36def checksum(data):
37 data += "\0" * (3 & -len(data)) # pad to multiple of 4 bytes 37 data_full_words = data[:len(data) & ~3]
38 data_last_word = data[len(data_full_words):]
39 data_last_word = "".join(reversed(data_last_word))
40 data_last_word += "\0" * (3 & -len(data)) # pad to multiple of 4 bytes
41 data = data_full_words + data_last_word
38 toret = 0 42 toret = 0
39 for offset in xrange(0, len(data), 4): 43 for offset in xrange(0, len(data), 4):
40 toret ^= struct.unpack_from("<L", data, offset)[0] 44 toret ^= struct.unpack_from("<L", data, offset)[0]