from typing import IO
import hashlib


def _hash_fileobj(fileobj: IO[bytes]) -> str:
    """ Compute sha256 hash of a file. File pointer will be reset to 0 on return. """
    fileobj.seek(0)
    h = hashlib.sha256()
    for block in iter(lambda: fileobj.read(2 ** 20), b""):
        h.update(block)
    fileobj.seek(0)
    return h.hexdigest()