How to UrlEncode a Sha1 string for a torrent tracker

做~自己de王妃 提交于 2019-12-25 08:29:52

问题


I try to send an HTTP request to a Torrent Tracker that must be with this form:

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

But the info_hash parameter must be UrlEncoded and it must look like: %AC%C3%B2%E4%33%D7%C7%47%5A%BB%59%41%B5%68%1C%B7%A1%EA%26%E2, So I use

System.Net.WebUtility.UrlEncode(info_hash)

And the output is the same as the input. I think the answer of this problem is obvious, but I didn't found it...


回答1:


A sha1 hash is 20 bytes long. The 40 characters long hex string is just used for humans. So you need to hex-decode before url-encoding.



来源:https://stackoverflow.com/questions/40021493/how-to-urlencode-a-sha1-string-for-a-torrent-tracker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!