Skip to content

Commit

Permalink
Print piece length and SHA-1 hash of each piece
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmaanjeetSandhu committed Sep 26, 2024
1 parent 2297ae8 commit 5affb81
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ def info_command(file_name: str) -> None:
print("Tracker URL:", torrent[b"announce"].decode(ENCODING))
print("Length:", torrent[b"info"][b"length"])
print("Info Hash:", info_hash)
print("Piece Length:", torrent[b"info"][b"piece length"])
pieces = torrent[b"info"][b"pieces"]
piece_hashes = [pieces[i : i + 20].hex() for i in range(0, len(pieces), 20)]
print("Piece Hashes: ")
for hash in piece_hashes:
print(hash)


def main() -> None:
Expand Down

0 comments on commit 5affb81

Please sign in to comment.