code: def file_sha1(path):
    
    sha1 = hashlib.sha1()
    with open(path, "rb") as f:
      while True:
        block = f.read(2 ** 10)
        if not block:
          break
        sha1.update(block)
      return sha1.hexdigest()
docs: Compute SHA1 hash of a file.