如何使用Url编码torrent跟踪器的Sha1字符串 [英] How to UrlEncode a Sha1 string for a torrent tracker

查看:195
本文介绍了如何使用Url编码torrent跟踪器的Sha1字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将HTTP请求发送到必须具有以下格式的Torrent跟踪程序:

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

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,所以我用

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...

推荐答案

sha1哈希长度为20个字节. 40个字符长的十六进制字符串仅用于人类.因此,您需要在url编码之前进行十六进制解码.

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.

这篇关于如何使用Url编码torrent跟踪器的Sha1字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆