Bencoding Algorithm - Torrent
Bencoding
→ Torrent file are ‘Bencoded’ and to extract the above fields we would need to parse the torrent file (Bencoded).
→ When you download the torrent file and give it to your client in order to download the content of the file. Client will first understand and extract the content described above. then it will get to know the location and where to get the actual piece of data.
Bencoding Specification
Bencoding | Supports : Strings, list, integers, and dictionaries |
---|---|
Strings | Format : <length> : <string> Example : om → 2 : om |
Integers | Format : i<integer> e, Example : 10 → i10e |
list | Format : l<bencoded values> e, Example : [”a”, “be”, 1] → l 1:a 2:be i1e e |
Dictionary | Format : d<bencoded string> <bencoded values> ….e, Example : { “a”: 1, “be”: 2} → d 1:a i1e 2:be i2e e (key value…) |
This post is licensed under CC BY 4.0 by the author.