Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

hash - What exactly is the info_Hash in a torrent file

I am reading lately a lot about hash from torrents, and magnetic links, etc. But there is a question I don't understand.

I have:

  • hash of a file
  • and the infohash of a torrent

Is the infohash = hash of the file ?

If yes what if the torrent describes 6 Files to download?

If no what does it stand for?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So I finally figured it out.

The “infohash” is the SHA1 Hash over the part of a torrent file that includes:

  1. ITEM: length(size) and path (path with filename)
  2. Name: The name to search for
  3. Piece length: The length(size) of a single piece
  4. Pieces: SHA1 Hash of EVERY piece of this torrent
  5. Private: flag for restricted access

To show this a little more I took a random torrent file and used the “BEncode Editor” from Ultima to make it more clearly to me.

BEncode Editor

As you can see the the red box marked the information part of the torrent file. The torrent file includes not the Hash of the items, but the hashes of every piece.

  • For item1 with: 1069496548
  • and item2 with: 223
  • It is together: 1069496771
  • With a piece size of: 524288
  • There are 2040 pieces. (1069496771/524288=2039.9032 approximately)
  • The pieces section includes 40800 byte of data what are 81600 + 2 chars in the file.
  • the +2 because 0x marks that this is hexadecimal.
  • A SHA1 hash has 40 0x chars or 20 Byte of data what are 2040 SHA1 hashes.

enter image description here

I am sorry that this information is about a torrent that leads to a illegal movie, but i wanted to use a torrent that realy exists.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...