Bencode Foo
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
- Decodes bencode strings, integers, lists, and dictionaries
- Binary-safe output (strings are []byte)
- Recursive descent parser with a manual cursor
- Minimal main.go for quick testing
- Learning reference and explanation: https://youtube.com/playlist?list=PLsdq-3Z1EPT1rNeq2GXpnivaWINnOaCd0
Thanks to @arpit_bhayani for the in depth explanation.
If you want more detail, see Bencode