且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是torrent文件中的info_Hash

更新时间:2023-12-03 21:09:58

所以我终于明白了。

infohash 是对包含以下内容的torrent文件的一部分进行SHA1散列处理:


  1. ITEM:长度(大小)和路径(带文件名的路径)

  2. 名称:要搜索的名称

  3. 片段长度:单个片段的长度(大小)
  4. 片段:SHA1这个torrent的每一部分的哈希

  5. 私有:限制访问的标志

为了展示这一点,我带了一个随机的torrent文件,并使用了来自Ultima的BEncode Editor,使它更加清晰。



正如您所看到的红色框标记了信息部分的torrent文件。
torrent文件不包含项目的哈希值,而是每个项目的哈希值。




  • 对于item1:1069496548

  • 和item2与:223

  • 它们在一起:1069496771 元件大小为:524288

  • 有2040件。 (2039,9032)

  • 片段包含40800字节的数据,文件中81600 + 2个字符。

  • +2因为0x标记这是十六进制的。

  • SHA1散列具有40个0x字符或20个字节的数据,2040个SHA1散列。





对不起,这些信息是关于导致非法电影的洪流,但我想用一个真正存在的洪流。


i am reading lately a lot about hash from torrents an magnetic links etc.

but there is a question i dont understand.

I have the hash of a file and the infohash of a torrent, is the infohash = hash of the file ?

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

If no what does it stand for.

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.

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. (2039,9032)
  • 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.

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.