MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / sha512sum

Function sha512sum

src/Crypt/CryptHash.py:6–17  ·  view source on GitHub ↗
(file, blocksize=65536, format="hexdigest")

Source from the content-addressed store, hash-verified

4
5
6def sha512sum(file, blocksize=65536, format="hexdigest"):
7 if type(file) is str: # Filename specified
8 file = open(file, "rb")
9 hash = hashlib.sha512()
10 for block in iter(lambda: file.read(blocksize), b""):
11 hash.update(block)
12
13 # Truncate to 256bits is good enough
14 if format == "hexdigest":
15 return hash.hexdigest()[0:64]
16 else:
17 return hash.digest()[0:32]
18
19
20def sha256sum(file, blocksize=65536):

Callers

nothing calls this directly

Calls 4

readMethod · 0.45
updateMethod · 0.45
hexdigestMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected