NBEncode is a .NET implementation of Bittorrent’s bencode protocol, written in C# 4.0. It encodes and decodes bencode streams, and has an easy to use object model.

Since bencoded .torrent files are going away in favour of magnet links, I decided to create this library as a small tribute to the format. Torrent-files have been an effective and innovative way of distributing bits, such as free or open sourced software.

Overview of NBEncode

NBEncode is a simple little library, thanks to the elegant simplicity of the bencode protocol. However, the library can easily be used for real world applications, for instance data storage, data transfer across networks, or certain classes of RESTful web services. The bencode protocol can be an attractive alternative to JSON or XML when you do not require built-in support for floating point numbers, GUIDs and the like, or when you are handling quite a lot of binary data.

NBEncode is..

    • Fully object oriented
    • Stream oriented
    • Builds a typesafe object graph when decoding, like the DOM way of reading XML.
    • Encodes from an object graph to a stream
    • Contains a full set of MSTest unit tests
    • Comes with a sample console application for parsing bencoded files, such as .torrent-files.
    • Released under the GNU GPL 3.0 license

The NBEncode sources are hosted on GitHub.com: https://github.com/lars1/NBEncode.git

Old code drop:
NBEncode source of august 5. 2012