Bencode
≈ 3 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Bencode (pronounced like Bee-encode) is the encoding used by the peer-to-peer file sharing system BitTorrent for storing and transmitting loosely structured data. It supports four different types of values: * byte strings, * integers, * lists (arrays), and * dictionaries (associative arrays). Bencoding is most commonly used in torrent files, and as such is part of the BitTorrent specification. These metadata files are simply bencoded dictionaries. Bencoding is simple and (because numbers are encoded as text in decimal notation) is unaffected by endianness, which is important for a cross-platform application like BitTorrent. It is also fairly flexible, as long as applications ignore unexpected dictionary keys, so that new ones can be added without creating incompatibilities.
Bencode (pronounced like Bee-encode) is the encoding used by the peer-to-peer file sharing system BitTorrent for storing and transmitting loosely structured data. It supports four different types of values: byte strings, integers, lists (arrays), and dictionaries (associative arrays). Bencoding is most commonly used in torrent files, and as such is part of the BitTorrent specification. These metadata files are simply bencoded dictionaries. Bencoding is simple and (because numbers are encoded as text in decimal notation) is unaffected by endianness, which is important for a cross-platform application like BitTorrent. It is also fairly flexible, as long as applications ignore unexpected dictionary keys, so that new ones can be added without creating incompatibilities.
Features
Bencode is a very specialized kind of binary coding with some unique properties: For each possible (complex) value, there is only a single valid bencoding; i.e. there is a bijection between values and their encodings. This has the advantage that applications may compare bencoded values by comparing their encoded forms, eliminating the need to decode the values. Bencoding serves similar purposes as data languages like JSON and YAML, allowing complex yet loosely structured data to be stored in a platform independent way. This allowing a linear memory storage for complex data.
See also
Canonical S-expressions BitTorrent
External links
Bencoding specification File_Bittorrent2 - Another PHP Bencode/decode implementation The original BitTorrent implementation in Python as standalone package Torrent File Editor cross-platform GUI editor for BEncode files bencode-tools - a C library for manipulating bencoded data and a XML schema like validator for bencode messages in Python Bento - Bencode library in Elixir. Beecoder - the file stream parser that de/encoding "B-encode" data format on Java using java.io.* stream Api. Bencode parsing in Java Bencode library in Scala Bencode parsing in C There are numerous Perl implementations on CPAN
Text derived from https://en.wikipedia.org/w/index.php?oldid=1344362789 under CC BY-SA 4.0; modifications have been made.