projects

Bencode Foo

2026 ยท github

Bencode Foo is a tiny decoder I wrote to understand bencoding at a low level. It focuses on the core primitives: strings, integers, lists, and dictionaries.

Overview

I wanted to understand BitTorrent internals beyond the high-level descriptions. Bencoding is small but subtle, and I wanted to learn it by implementing a decoder from scratch with a manual cursor and recursive parsing. The project is a learning artifact, not a product.

The Solution

I wrote a minimal Go decoder that parses bencode using a cursor-based recursive descent approach. It is binary-safe and returns strings as []byte.

Technical Details

Thanks to @arpit_bhayani for the in depth explanation.

If you want more detail, see Bencode