Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing a torrent file - hash info. (Erlang)
    primarykey
    data
    text
    <p>I'm trying to come up with the correct url-encoded info hash to send to the tracker in order to get the peers list.</p> <p>For testing, I tried parsing the torrent in <a href="http://www.legittorrents.info/index.php?page=torrent-details&amp;id=788f590f28a799cc1009a9b780b649fd6f0a2e91" rel="nofollow">this url</a>.</p> <p>After opening the file, manually cut the info dictionary piece and SHA1-hash it's value I get this binary value:</p> <p>&lt;&lt;84,124,15,255,155,171,156,168,91,46,204,24,249,116,110, 139,202,167,163,54>></p> <p>The ASCII string retrieved from the latter binary value is 788f590f28a799cc1009a9b780b649fd6f0a2e91, and it's the same value mentioned in the site.</p> <p>So let's assume everything is correct until now (isn't it?).</p> <p>After encoding the binary value using the url-encoding function below I get T%7c%0f%ff%9b%ab%9c%a8%5b.%cc%18%f9tn%8b%ca%a7%a36 , which is not even close to the correct urlencoded value that I should send to the tracker. (I get a not-found error message when I send this to the tracker, plus, it's not matched to the value I see using wireshark which is x%8fY%0f%28%a7%99%cc%10%09%a9%b7%80%b6I%fdo%0a.%91 ). </p> <p>The URL Encoding function I'm using:</p> <pre><code>encode(&lt;&lt;Bin:20/binary-unit:8&gt;&gt;)-&gt; %io:format("~p~n", [binary_to_list(Bin)]), encode(binary_to_list(Bin)); encode(List) -&gt; do_encode(List). do_encode([])-&gt; []; do_encode([H|T]) when H&gt;=$a, H=&lt;$z -&gt; [H| encode(T)]; do_encode([H|T]) when H&gt;=$A, H=&lt;$Z -&gt; [H| encode(T)]; do_encode([H|T]) when H&gt;=$0, H=&lt;$9 -&gt; [H| encode(T)]; do_encode([H|T]) when H==$- -&gt; [H| encode(T)]; do_encode([H|T]) when H==$. -&gt; [H|do_encode(T)]; do_encode([H|T]) when H==$* -&gt; [H|do_encode(T)]; do_encode([H|T]) -&gt; to_hex(H) ++ encode(T). hex(N) when N &lt; 10 -&gt; $0+N; hex(N) when N &gt;= 10, N &lt; 16 -&gt; $a+(N-10). to_hex(N) when N &lt; 256 -&gt; [$%, hex(N div 16), hex(N rem 16)]. </code></pre> <p>Is the function above wrong? I'm a kind of a newbie when it comes to raw-data handling. so help/ideas are much appreciated! Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload