in reply to BitTorrent info_hash and Tie::UrlEncoder
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: BitTorrent info_hash and Tie::UrlEncoder
by Anonymous Monk on Sep 21, 2007 at 08:16 UTC |