链接:http://wiki.vuze.com/w/Scrape http://wiki.vuze.com/w/Scrapeuser3690414 发布的内容几乎解释了不同键代表的含义。
要解释原始编码字符串:
d5:filesd20:¼€™rÄ2ÞÊþVA .]á^¦d8:completei285e10:downloadedi22911e10:incompletei9eeee
您需要了解 Bencoding 的工作原理:https://wiki.theory.org/BitTorrentSpecification#Bencoding https://wiki.theory.org/BitTorrentSpecification#Bencoding
这里最重要的是要知道,编码字典中的每个条目都是一个核心价值-pair.
Where Key is a 字节串
and Value以下类型之一:字节串, integer, a list or a 字典.
考虑到这一点,原始字符串可以像这样分解:
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
希望这有助于理解“bencoded.php”的输出。
edit.
如果你想制作 160 位大端 SHA1 信息哈希 [¼€™rä2ÞÊþVA .]á^]
更易于人类阅读,我建议您将其输出为 40 字节十六进制编码字符串:
0xBC801B9D9972C432DECAFE56410F092E5DE15EA6