hash - 种子 info_hash 参数

标签 hash bittorrent url-parameters

如何计算info_hash参数?又名对应于信息字典的哈希??

来自官方规范:

info_hash The 20 byte sha1 hash of the bencoded form of the info value from the metainfo file. Note that this is a substring of the metainfo file. This value will almost certainly have to be escaped.

这是否意味着简单地从元信息文件中获取子字符串并对代表字节进行 sha-1 哈希?

...因为我尝试了 12 次但没有成功,这意味着我已将生成的哈希值与我最终应该得到的哈希值进行了比较..并且它们不同..+跟踪器响应是失败,未知 torrent 。 ..或者什么东西

那么如何计算 info_hash 呢?

最佳答案

图元文件已经编码,所以我不明白为什么要再次编码?

我终于在 Java 代码中得到了这个工作,这是我的代码:

byte metaData[];  //the raw .torrent file

int infoIdx = ?;  //index of 'd' right after the "4:info" string

info_hash = SHAsum(Arrays.copyOfRange(metaData, infoIdx, metaData.length-1));

这假设“info” block 是 torrent 文件中的最后一个 block (错误?)

不要进行排序或类似的操作,只需使用原始 torrent 文件的子字符串即可。

对我有用。

关于hash - 种子 info_hash 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10191480/

相关文章:

ruby - 如何在 ruby​​ 中以简单而强大且可移植的方式以可验证的方式签署文本?

decode - 从 coppersurfer.tk 抓取文件解码磁铁 uri

javascript - jQueryMobile 中的动态链接

java - 洪流相关 : tracker response on UDP protocol (Update #3 - working)

javascript - 从 iframe 中获取 iframe 的 URL 参数

java - 使用 param 标签抑制空参数

perl - 无法获取作为模块中引用传递的哈希值

ruby - 在 Ruby 中获取用于哈希中的键的特定对象的便捷方法?

mysql - 为什么 MySQL 的 ENCRYPT 在每次调用时返回不同的结果?

python - 如何使用twisted通过UDP协议(protocol)发送参数