Dictionaries are stored as d[key1][value1][key2][value2][...]e. Keys and values appear alternately. Keys must be strings and must be ordered alphabetically. For example, {apple-red, lemon-yellow, violet-blue, banana-yellow} is stored as:
Data in a torrent file is bencoded as a dictionary, with no other header. Because of the alphabetic-order of dictionary keys, the first seven characters of the file will be "d4infod". The top-level dictionary has the following keys:
The URL of the tracker for the torrent. For example, 29:http://tracker.example.com:80
announce-list
list
A listing of the URLs of alternate trackers for the torrent. The URLs are divided into groups (each is a list), trackers in each group may be shuffled, and groups are processed in the order they appear. Optional.
creation date
integer
The creation date and time, expressed as the number of seconds since January 1, 1970 12:00. Optional.
comment
string
Any user comment for the torrent. Optional.
created by
string
Application-generated string that may include its name, version, etc. Optional.
The info key corresponds to the files in the torrent. There are two-forms: a single-file format that contains only a single file, and a multi-file format that may contain multiple files and directories. The info key itself corresponds to a another (essentially "nested") dictionary with the keys as follows:
The proposed name of directory to store the files.
files
list (of dictionary)
A list of dictionaries, one dictionary for each file in the torrent, which is described in the next table.
A dictionary in the file list corresponds to one file and contains the following:
Key
Type
Description
length
integer
The length of the file, in bytes.
path
list (of string)
A list of strings representing the relative path to the file. For example, l6:source3:bin8:test.exee corresponds to the path "<directory name>\source\bin\test.exe".