我有一个问题,不知道如何将 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/