问题
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