Module percent_encoding

Source
Expand description

This module contains functions for percent decoding infohashes and peer IDs.

Percent encoding is an encoding format used to encode arbitrary data in a format that is safe to use in URLs. It is used by the HTTP tracker protocol to encode infohashes and peer ids in the URLs of requests.

BitTorrent infohashes and peer ids are percent encoded like any other arbitrary URL parameter. But they are encoded from binary data (byte arrays) which may not be valid UTF-8. That makes hard to use the percent_encoding crate to decode them because all of them expect a well-formed UTF-8 string. However, percent encoding is not limited to UTF-8 strings.

More information about “Percent Encoding” can be found here:

Functions§

percent_decode_info_hash
Percent decodes a percent encoded infohash. Internally an InfoHash is a 20-byte array.
percent_decode_peer_id
Percent decodes a percent encoded peer id. Internally a peer Id is a 20-byte array.