Posts Tagged ‘bencoding’

Bencoding values for the BitTorrent protocol is explained in a Wikipedia article on Bencoding or in the more general BitTorrent protocol page.

Briefly, there are four types :

  • byte strings : [string length encoded in base ten ASCII]:[string data] ;
  • integers : i[integer encoded in base ten ASCII]e ;
  • lists : l[bencoded values]e ;
  • and dictionaries : d[bencoded string][bencoded element]e.

Byte strings can be strings represented as byte strings (such as the description of the exchanged data), as well as an array of bytes (such as a hash). Representing them with the .Net strings can thus lead to errors. Hence we shall keep the byte array representation.

Integers can be longs, hence we represent them with int64.

Read more »