def of_file(self, abspath, nbytes=<NUM_LIT:0>, chunk_size=<NUM_LIT>):
if nbytes < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if chunk_size < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if (nbytes > <NUM_LIT:0>) and (nbytes < chunk_size):<EOL><INDENT>chunk_size = nbytes<EOL><DEDENT>m = self.hash_algo()<EOL>with open(abspath, "<STR_LIT:rb>") as f:<EOL><INDENT>if nbytes:  <EOL><INDENT>have_reads = <NUM_LIT:0><EOL>while True:<EOL><INDENT>have_reads += chunk_size<EOL>if have_reads > nbytes:<EOL><INDENT>n = nbytes - (have_reads - chunk_size)<EOL>if n:<EOL><INDENT>data = f.read(n)<EOL>m.update(data)<EOL><DEDENT>break<EOL><DEDENT>else:<EOL><INDENT>data = f.read(chunk_size)<EOL>m.update(data)<EOL><DEDENT><DEDENT><DEDENT>else:  <EOL><INDENT>while True:<EOL><INDENT>data = f.read(chunk_size)<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>m.update(data)<EOL><DEDENT><DEDENT><DEDENT>return m.hexdigest()<EOL>
Use default hash method to return hash value of a piece of a file

        Estimate processing time on:

        :param abspath: the absolute path to the file.
        :param nbytes: only has first N bytes of the file. if 0, hash all file.
        :param chunk_size: The max memory we use at one time.

        CPU = i7-4600U 2.10GHz - 2.70GHz, RAM = 8.00 GB
        1 second can process 0.25GB data

        - 0.59G - 2.43 sec
        - 1.3G - 5.68 sec
        - 1.9G - 7.72 sec
        - 2.5G - 10.32 sec
        - 3.9G - 16.0 sec

        ATTENTION:
            if you change the meta data (for example, the title, years
            information in audio, video) of a multi-media file, then the hash
            value gonna also change.