php - 在 PHP 中翻译 torrent 的公告请求中的 info_hash

标签 php tracker utorrent info-hash

我有一个问题,不知道如何将 info_hash 值“转换”为真正的哈希值。 以下是 uTorrent 向我的跟踪器发布消息时我收到的示例:

{
passkey: "77ec6a27adcc441648d66d0b873550e4",
info_hash: "YNvÿ@p",
peer_id: "-UT3430-89 ",
port: "54790",
uploaded: "0",
downloaded: "491520",
left: "24928863",
corrupt: "0",
key: "A2DD5E96",
numwant: "200",
compact: "1",
no_peer_id: "1"
}

我想了解的是如何获取这个奇怪的值:“YNvÿ@p”并获取信息哈希作为sha1(例如:594E98760099B1CFC3BFAA4070C0CC02F6C1AA90)? 我在我的服务器上使用 PHP。

现在我已经阅读了以下声明:

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. The info-hash must be the hash of the encoded form as found in the .torrent file, regardless of it being invalid. This value will almost certainly have to be escaped.

但这并没有帮助我理解正在发生的事情。

最佳答案

好的,我找到了解决方案。 由于某种原因,PHP 中的 $_GET (我们使用 CodeIgniter)不会获取完整的二进制数据,看起来它由于某种原因正在剥离它。剩下的就只有“YNvÿ@p”了,但事实上,还有一些未知的二进制符号被扔在路上。

所以...我所做的是获取完整的 URL 参数:

$parts = parse_url($_SERVER['REQUEST_URI']);

然后,我在“info_hash”键中得到了这个值:

D%3b%16%01%b2%af%d7%cbT%e1%a1%d0A%20%20%f7%ce%c2%d3%bf

之后我就做了这个 Action :

$info_hash = bin2hex(urldecode($parts["info_hash"]));

并获得完整的哈希值!

@Sammitch,感谢您在此事上为我指明了正确的方向!

关于php - 在 PHP 中翻译 torrent 的公告请求中的 info_hash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32912719/

相关文章:

python - 查找给定 torrent 文件的播种者/对等者 IP 地址的最佳方法是什么

bittorrent - 如何在 uTorrent 中准确计算 torrent 的可用性

php - MySQL查询只完成了80%的查询,为什么它漏掉了20%呢?

php - 从电视节目文件名中提取名称、季节和剧集

php - 解码 Torrent 跟踪器抓取的 Torrent 哈希?

android - 为什么实现Google Analytics时没有创建R.xml文件资源?

php - 我正在使用的选择查询不起作用。有人可以指导我正确的方法吗?

php - MySQL 多表关系

indexing - 如何强制跟踪器重新索引文件夹?

c# - 通过 .NET 使用 uTorrent Web API