<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hash_file(tar_filename):
 """hash the file"""

    hasher = sha1()
    with open(tar_filename, 'rb') as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            hasher.update(buf)
            buf = afile.read(BLOCKSIZE)
    data = HASHTMPL % (hasher.hexdigest(), os.path.basename(tar_filename))
    create_file('%s.sha1' % tar_filename, data)