What exactly is the info_Hash in a torrent file

Emetiel picture Emetiel · Feb 5, 2015 · Viewed 52k times · Source

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?

Answer

Emetiel picture Emetiel · Feb 19, 2015

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.