code: def get_file_hash( fd, hashfunc, fd_len=None ):
      
  
      h = hashfunc()
      fd.seek(0, os.SEEK_SET)
  
      count = 0
      while True:
          buf = fd.read(65536)
          if len(buf) == 0:
              break
  
          if fd_len is not None:
              if count + len(buf) > fd_len:
                  buf = buf[:fd_len - count]
  
          h.update(buf)
          count += len(buf)
  
      hashed = h.hexdigest()
      return hashed
docs: Get the hex-encoded hash of the fd's data