Python ( ), 2-4 ( 32- Python, , I/O, ). , , ( , , , ). - :
with open(file, 'rb') as f:
hasher = hashlib.sha256()
while True:
block = f.read(64 * (1 << 20))
if not block:
break
hasher.update(block)
print('SHA256 of file is %s' % hasher.hexdigest())
, "" -arg iter
functools
, while
:
for block in iter(functools.partial(f.read, 64 * (1 << 20)), b''):
hasher.update(block)