def digest_file(infile, checksum='md5'):
    if not __salt__['file.file_exists'](infile):
        raise salt.exceptions.CommandExecutionError(
                "File path '{0}' not found.".format(infile))

    with open(infile, 'rb') as f:
        file_hash = __salt__['hashutil.digest'](f.read(), checksum)

    return file_hash
Check the permissions on files and chown if needed
dataset/ETHPy150Open saltstack/salt/salt/modules/hashutil.py/digest_file--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/check_perms