How to UrlEncode a Sha1 string for a torrent track

2019-09-04 11:56发布

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条回答
男人必须洒脱
2楼-- · 2019-09-04 12:11

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.

查看更多
登录 后发表回答