generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: Bencoding Algorithm - Torrent | ||
date: 2023-10-05 10:00:00 -500 | ||
categories: [algorithm] | ||
tags: [algorithm, torrent, bencoding] | ||
--- | ||
|
||
|
||
### 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…) | |