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

Function blockchecksums

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

Returns a list of weak and strong hashes for each block of the defined size for the given data stream.

(instream, blocksize=4096)

Source from the content-addressed store, hash-verified

121
122
123def blockchecksums(instream, blocksize=4096):
124 """
125 Returns a list of weak and strong hashes for each block of the
126 defined size for the given data stream.
127 """
128 weakhashes = list()
129 stronghashes = list()
130 read = instream.read(blocksize)
131
132 while read:
133 weakhashes.append(weakchecksum(bytes(read))[0])
134 stronghashes.append(hashlib.md5(read).hexdigest())
135 read = instream.read(blocksize)
136
137 return weakhashes, stronghashes
138
139
140def patchstream(instream, outstream, delta):

Callers

nothing calls this directly

Calls 6

listClass · 0.85
weakchecksumFunction · 0.85
bytesFunction · 0.85
hexdigestMethod · 0.80
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected