如何为torrent跟踪器UrlEncode Sha1字符串

时间:2016-10-13 12:49:14

标签: c# .net url bittorrent torrent

我尝试向必须使用此格式的Torrent跟踪器发送HTTP请求:

bt1.archive.org GET /announce?info_hash=ACC3B2E433D7C7475ABB5941B5681CB7A1EA26E2 HTTP/1.1 Host: bt1.archive.org Connection: keep-alive Accept: text/html User-Agent: CSharp

但是info_hash参数必须是UrlEncoded并且必须如下所示:%AC%C3%B2%E4%33%D7%C7%47%5A%BB%59%41%B5%68%1C%B7%A1%EA%26%E2,所以我使用

System.Net.WebUtility.UrlEncode(info_hash)

输出与输入相同。 我认为这个问题的答案是显而易见的,但我没有找到它......

1 个答案:

答案 0 :(得分:1)

sha1哈希长度为20个字节。 40个字符长的十六进制字符串仅用于人类。所以你需要在url-encoding之前进行十六进制解码。