简体   繁体   English

解码Torrent跟踪器的Torrent Hash?

[英]Decode Torrent Hash of Torrent tracker scrape?

I am using BEncoded PHP Library to decode the bencoded response from a Bittorrent tracker. 我正在使用BEncoded PHP Library来解码来自Bittorrent跟踪器的bencoded响应。

The response of Tracker is: Tracker的回应是:

d5:filesd20:¼€™rÄ2ÞÊþVA  .]á^¦d8:completei285e10:downloadedi22911e10:incompletei9eeee

after decoding it using the below code: 使用以下代码解码后:

require 'bencoded.php';

$be = new BEncoded;
//Response saved in scrape.txt
$data =file_get_contents('scrape.txt');
print_r($be->Decode($data));

the output is: 输出是:

Array ( [files] => Array ( [¼€™rÄ2ÞÊþVA  .]á^¦] => Array ( [complete] => 285 [downloaded] => 22911 [incomplete] => 9 [isDct] => 1 ) [isDct] => 1 ) [isDct] => 1 )

My Problem my problem in the above output is how to decode those mysterious letters in output. 我的问题我在上面的输出中的问题是如何解码输出中的那些神秘字母。

The link: http://wiki.vuze.com/w/Scrape posted by user3690414 pretty much explains what the different keys stands for. 链接: http ://wiki.vuze.com/w/Scrape发布者user3690414几乎解释了不同的键代表什么。

To interpret the raw bencoded string: 要解释原始的bencoded字符串:

d5:filesd20:¼€™rÄ2ÞÊþVA  .]á^¦d8:completei285e10:downloadedi22911e10:incompletei9eeee

you need to understand how bencoding works: https://wiki.theory.org/BitTorrentSpecification#Bencoding 你需要了解bencoding是如何工作的: https ://wiki.theory.org/BitTorrentSpecification#Bencoding

The most essential to know here is that that every entry in a bencoded dictionary is a Key,Value -pair. 这里要知道的最重要的是,bencoded字典中的每个条目都是Key,Value -pair。
Where Key is a byte string 其中Key是一个字节字符串
and Value one of the following types: byte string , integer , a list or a dictionary . 以下类型之一: 字节字符串整数列表字典

With that in mind the raw string can be broken down like this: 考虑到这一点,原始字符串可以像这样分解:

d               // The first d indicates the start of the Root dictionary
 5:files            // that has a Key with a 5 byte string name 'files',
  d                     // the value of the 'files'-key is a second dictionary
   20:¼€™rÄ2ÞÊþVA  .]á^¦    // that has a Key 20 byte = 160 bit big endian SHA1 info-hash
    d                       // the value of that key is a third dictionary
     8:complete                 // that has a Key with a 8 byte string name 'complete',
      i285e                         // the value of that key is a Integer=285
     10:downloaded              // that has a Key with a 10 byte string name 'downloaded',
      i22911e                       // the value of that key is a Integer=22911
     10:incomplete              // that has a Key with a 10 byte string name 'incomplete',
      i9e                           // the value of that key is a Integer=9
    e                       // this e indicates the end of the third dictionary
  e                     // this e indicates the end of the second dictionary
e               // this e indicates the end of the Root dictionary

Hope this helps to understand the output from 'bencoded.php'. 希望这有助于理解'bencoded.php'的输出。

edit. 编辑。
If you want to make the 160 bit big endian SHA1 info-hash [¼€™rÄ2ÞÊþVA .]á^¦] 如果你想制作160位大端的SHA1信息哈希[¼€™rÄ2ÞÊþVA。]á^ |]
more human readable, I suggest that you output it as 40 byte hex-encoded string: 更人性化,我建议您将其输出为40字节的十六进制编码字符串:
0xBC801B9D9972C432DECAFE56410F092E5DE15EA6

If you are referring to the mangled key of files array then it's raw infohash - check out the spec: 如果您指的是files数组的错位密钥,那么它是原始的infohash - 请查看规范:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM