diff options
-rwxr-xr-x | makecab.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 | ||
36 | def checksum(data): | 36 | def 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] |