Jump to content

Translating info_hash in the announce request


Recommended Posts


I'm having an issue to understand how can I "translate" the info_hash value to a real hash.

Here's an example of what I'm getting from uTorrent when it's announcing to my tracker:



What I'm trying to understand is how do I take this strange value: "YNvÿ@p" and get the info hash as sha1 (like: 594E98760099B1CFC3BFAA4070C0CC02F6C1AA90)?

I'm using PHP on my server.


Now I've read already the following statements:

info_hashThe 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.

But it didn't help me much to understand what's going on... 




Link to comment
Share on other sites

You can't use json for storing announce info. It's not binary-safe.


Hi, eventually I solved the problem. Just couldn't post it here because I can't post more then 1 posts per day :/


Anyway, the JSON wasn't the problem, although you right. It's not the best idea to trust JSON for showing binary information, I tried to store it to txt file on the server also without JSON, still the same problem.


Anyway, the framework I'm using in CodeIgniter, and from some reason I found out that it's stripping some binary chars (I guess) from the GET URL, because when I opened a new PHP file without any framework, and coded it so it may save the GET parameters it's getting into a .txt file, I saw that the info_hash was full in it's binary mode, non-stripped like in CodeIgniter.


So... after some digging, found a solution for that, in order to get the $_GET parameters I did that:

$parts = parse_url($_SERVER['REQUEST_URI']);$info_hash = bin2hex(urldecode($parts["info_hash"]));

And it solved it.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...