This should be recognized just fine by the tracker.my $info_hash = "db8babd3f3662166ee9019e29fd7345af8b2b59a"; $info_hash =~ s/(..)/%$1/g;
However, if you really want things like %5A to come out as "Z" instead (since they are characters that are safe to use in a URI), then use URI::Escape to do the escaping. It is part of LWP, so is quite common to have installed. First decode the hash from its printable form back into raw bytes and then use URI::Escape to encode those bytes into a URI-safe string.
BTW, if you are computing the info_hash of a bittorrent file, you have the option of getting the result in an printable hex-encoded form "db8b.." or raw bytes "\0xdb\0x8b..." (when you compute the SHA1 hash). You might as well choose to get it in the raw form if you pass it directly to uri_escape.use URI::Escape; my $info_hash = "db8babd3f3662166ee9019e29fd7345af8b2b59a"; $info_hash =~ s/(..)/chr hex $1/ge; # or a suitable call to pack, but I'm lazy right now my $uri_hash = uri_escape($info_hash);
blokhead
In reply to Re: BitTorrent info_hash and Tie::UrlEncoder
by blokhead
in thread BitTorrent info_hash and Tie::UrlEncoder
by jk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |