Search for Best Torrents

Cheap Canon Lenses

Jul 21, 2014

What is Bencoding ?

Bencoding is a way to specify and organize data in a terse format. It supports the following types: byte strings, integers, lists, and dictionaries.

Bencoded Strings

Bencoded strings are encoded as follows: :, or key:value
Note that there is no constant beginning delimiter, and no ending delimiter.
Example4:spam represents the string "spam"


Integers are encoded as follows: ie
The initial i and trailing e are beginning and ending delimiters. You can have negative numbers such as i-3e. Only the significant digits should be used, one cannot pad the Integer with zeroes. such as i04e. However, i0e is valid.
Examplei3e represents the integer "3"
  • NOTE: The maximum number of bit of this integer is unspecified, but to handle it as a signed 64bit integer is mandatory to handle "large files" aka .torrent for more that 4Gbyte.


Lists are encoded as follows: le
The initial l and trailing e are beginning and ending delimiters. Lists may contain any bencoded type, including integers, strings, dictionaries, and even lists within other lists.
Example: l4:spam4:eggse represents the list of two strings: [ "spam", "eggs" ]


Dictionaries are encoded as follows: de
The initial d and trailing e are the beginning and ending delimiters. Note that the keys must be bencoded strings. The values may be any bencoded type, including integers, strings, lists, and other dictionaries. Keys must be strings and appear in sorted order (sorted as raw strings, not alphanumerics). The strings should be compared using a binary comparison, not a culture-specific "natural" comparison.
Exampled3:cow3:moo4:spam4:eggse represents the dictionary { "cow" => "moo", "spam" => "eggs" } 
Exampled4:spaml1:a1:bee' represents the dictionary { "spam" => [ "a", "b" ] } 
Exampled9:publisher3:bob17:publisher-webpage15:www.example.com18:publisher.location4:homee represents { "publisher" => "bob", "publisher-webpage" => "", "publisher.location" => "home" }

No comments: