BT seed file format

Source: Internet
Author: User
Tags sha1 sha1 hash

The BT seed file uses a coding method called Bencoding to hold the data.
Bencoding existing four types of data: Srings (String), integers (integer), lists (list), dictionaries (dictionary)
The encoding rules are as follows:
Strings (string) encoded as:< string length >:< string >
For example: 4:test is represented as the string "test"
4: Example Expression for string "example"
String length unit is byte
No start or end tag

Integers (integer) is encoded as a:i< integer >e
Start tag I, end tag for E
For example: i1234e is represented as an integer 1234
i-1234e represented as integer-1234
Integer has no size limit
I0E is represented as an integer 0
I-0E is illegal
With 0 The beginning of the illegality as: i01234e for illegal

Lists (list) is encoded as: l<bencoding encoding type >e
Start marked as l, end marked E
The list can contain any bencoding encoding type, including integers, strings, lists, dictionaries.
For example: L4:test5abcdee is represented as two strings ["Test", "ABCDE"]

Dictionaries (dictionary) is encoded as a d<bencoding string ><bencoding encoding type >e
Start marked D, end marked E
Keyword must be a bencoding string
Value can be of any bencoding encoding type
For example: D3:agei20ee is represented as {"Age" = 20}
D4:path3:c:\8:filename8:test.txte is represented as {"path" = "C:\", "filename" = "test.txt"}

The specific file structure of BT Seed is as follows:
All content must be of the bencoding encoding type.
The entire file is a dictionary structure that contains the following keywords

d8:announce: Tracker server URL (string)
announce-list (optional): Alternate tracker server list (list)
Creation Date (optional): Time of seed creation, UNIX standard time format, number of seconds from 1970 January 1 00:00:00 to Creation time (integer)
Comment (optional): note (string)
created by (optional): Information for creating a person or creating a program (String)
Info: A dictionary structure that contains the primary information for a file in two cases: Single file structure or multiple file structure
The single file structure is as follows:
Length: File length, Unit byte (integer)
md5sum (optional): Long 32 Characters of the file's MD5 checksum, BT does not use this value, just to be compatible with some programs reserved! String
Name: File name (string)
piece length: size of each block, Unit byte (integer)
pieces: value of SHA1 hash per block (binary format, 20 byte size)

The multi-file structure is as follows:

D
Files
: A dictionary structure that includes the following 3
Length: File length, Unit byte (integer)
md5sum (optional): Same in single file structure
Path: File paths and names, is a list structure, such as \test\test.txt list for L4:test8test.txte

E
....

Name: top-Most directory name (string)
piece Length: The size of each block, same as in the single file structure
pieces: value of SHA1 hash per block (binary format, 20 byte size)

In any case, it ends with ee . The preceding e-match info dictionary structure, the last e-matching file head dictionary structure;

Instance:
Open one in Notepad. torrent can look something like the following
d8:announcehttp://www.manfen.net:7802/announce:creation Datei 1076675108e4:infod6:lengthi17799e4:name:MICROSOFT. Windows.2000.and.nt4.source.code-sceneleader.torrent:piece lengthi32768e6: Pieces:? W 躐 緕 T Feng ee

It's easy to see
Announce=http://www.manfen.net:7802/announce
Creation date=1076675108 seconds (02/13/04 20:25:08)
Name=microsoft. Windows.2000.and.nt4.source.code-sceneleader.torrent
length=17799 bytes
Piece length=32768 bytes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.