MCPcopy Create free account
hub / github.com/ActiveState/code / weakchecksum

Function weakchecksum

recipes/Python/577518_Rsync_Algorithm/recipe-577518.py:165–175  ·  view source on GitHub ↗

Generates a weak checksum from an iterable set of bytes.

(data)

Source from the content-addressed store, hash-verified

163
164
165def weakchecksum(data):
166 """
167 Generates a weak checksum from an iterable set of bytes.
168 """
169 a = b = 0
170 l = len(data)
171 for i in range(l):
172 a += data[i]
173 b += (l - i)*data[i]
174
175 return (b << 16) | a, a, b

Callers 2

rsyncdeltaFunction · 0.85
blockchecksumsFunction · 0.85

Calls 1

rangeFunction · 0.85

Tested by

no test coverage detected